This is a migrated thread and some comments may be shown as answers.

problem about Fiddler script and regular expression

4 Answers 666 Views
Fiddler Classic
This is a migrated thread and some comments may be shown as answers.
Danny
Top achievements
Rank 1
Danny asked on 09 Jan 2015, 12:04 PM
Hello Eric ,

Thanks for bring us Fiddler. It's pretty useful.

Here is the problem:

 if (oSession.HostnameIs("www.test.com"))  { 
            oSession.utilDecodeResponse();
             if (oSession.utilFindInResponse("cacheKey",false) > -1){ 
                    var oBody = oSession.GetResponseBodyAsString (); 
                    var regex =/value=\"(.*)\" id=\"cacheKey/i;
                    if(oBody.match(regex)){
                        MessageBox.Show("AAAA" );
                        var cachekey = RegExp.$1;            // <--------------------   Error Line
                      }

Every time i save it, fiddler report :

Object doesn't support this property or method.

I try many times but the problem is still here.

Could you help me?  thanks anyway!


        

4 Answers, 1 is accepted

Sort by
0
Danny
Top achievements
Rank 1
answered on 09 Jan 2015, 02:03 PM
The response body may contain following string:


<input type="text" class="hiddeninput" value="cf7d7002bba04bd2be5de3a3e5fcdb84" id="cacheKey" name="cacheKey" />


Thanks again!
0
Eric Lawrence
Telerik team
answered on 10 Jan 2015, 04:25 PM
Hello, Danny--

JScript.NET (the language behind FiddlerScript) doesn't allow use of the RegExp object when the /fast option is used (which Fiddler sets): http://msdn.microsoft.com/de-de/library/40a0cc3e%28v=vs.71%29.aspx

Instead of the RegExp.$1 you'll instead need to use one of the other methods of your regex object to perform your extraction.

Regards,
Eric Lawrence
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Breeze
Top achievements
Rank 1
answered on 14 Mar 2015, 08:43 AM
Hi, 
I encountered with the same problem and not able to solve it.
The string in the oBody is:  "count"=7
 I try to grep it by: var patt = /"count"=(\d+)/
and finally doubles the number.
How to do it without using $1?

Thanks.

0
Eric Lawrence
Telerik team
answered on 17 Mar 2015, 02:57 PM
Hello, Breeze--

I think you're asking: "How do I manipulate a string in .NET?" You can either use .NET Regular Expression objects or simple string parsing.

Your best bet would be to ask such questions in a general programming forum, like StackOverflow.com, for instance, as they don't really have anything to do with Fiddler.

Regards,
Eric Lawrence
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Fiddler Classic
Asked by
Danny
Top achievements
Rank 1
Answers by
Danny
Top achievements
Rank 1
Eric Lawrence
Telerik team
Breeze
Top achievements
Rank 1
Share this question
or