problem about Fiddler script and regular expression

5 posts, 0 answers
  1. Danny
    Danny avatar
    22 posts
    Member since:
    Jun 2014

    Posted 09 Jan 2015 Link to this post

    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!


            

  2. Danny
    Danny avatar
    22 posts
    Member since:
    Jun 2014

    Posted 09 Jan 2015 Link to this post

    The response body may contain following string:


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


    Thanks again!
  3. Eric Lawrence
    Admin
    Eric Lawrence avatar
    833 posts

    Posted 10 Jan 2015 Link to this post

    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.

     
  4. Breeze
    Breeze avatar
    1 posts
    Member since:
    Mar 2015

    Posted 14 Mar 2015 in reply to Eric Lawrence Link to this post

    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.

  5. Eric Lawrence
    Admin
    Eric Lawrence avatar
    833 posts

    Posted 17 Mar 2015 Link to this post

    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.

     
Back to Top