Using RegExp.$1 in Fiddlers CustomRules.js

555 views Asked by At

I've been using Fiddler for a few days now, extending CustomRules.js with my own logic.

I tried to grab some information out of the response body using regular expressions

This is what I copied from http://msdn.microsoft.com/en-us/library/bahdt634%28v=VS.71%29.aspx

    var s : String;
    var re : RegExp = new RegExp("d(b+)(d)","ig");
    var str : String = "cdbBdbsbdbdz";
    var arr : Array = re.exec(str);
    s = RegExp.$1;

However using this in fiddler will give an error when I save the file. Saying RegExp.$1 is not supported.

I assume this is related to (http://msdn.microsoft.com/en-us/library/bahdt634%28v=VS.71%29.aspx)

Note The properties of the RegExp object are not available when running in fast mode, the default for JScript .NET. To compile a program from the command line that uses these properties, you must turn off the fast option by using /fast-. It is not safe to turn off the fast option in ASP.NET becafast mode is not switched of.

However how do I switch of fast mode in CustomRules.js? Is this possible?

1

There are 1 answers

0
katspaugh On BEST ANSWER

Don't know about JScript, but in JavaScript RegExp.prototype.exec returns null or an array, which members are the matched substring followed by its captured groups.

So your s would be arr[1].