If you are just interested in getting a marker, you cannot just execute the regex:
var str = '<script>var a = 1;...ak.setRequestHeader("oauth_token", ae);...</script>'; var token = str.match(/setRequestHeader\("oauth_token",\s*([^)]+)/)[1];
Although this suggests that ae is the actual string value. If it is a variable, this approach will not work as easily.
Edit: if it is a variable, you can do something like:
str.replace(/\w+\.setRequestHeader\([^,]+,\s*([^)]+)\s*\);/, 'oauthToken = \1';
Before running the JavaScript returned from the page, the global oauthToken (note the missing "var") will contain the value of the token, assuming that the code is evaluated in the same area as the caller.
source share