Match a string in body using Regex

3 posts, 0 answers
  1. nasekt
    nasekt avatar
    40 posts
    Member since:
    Aug 2014

    Posted 07 Oct 2014 Link to this post


       var bodyString = oSession.GetResponseBodyAsString();
    if (oSession.oResponse.MIMEType.Contains("html")) {
    var regex = /jimmy/;
    if (regex.test(bodyString)) {

    oSession.oRequest.FailSession (404, "Blocked", "Fiddler blocked product service request");
    }
    }

    Basically, How do I tell Regex to find the string jimmy present in body, if found, then block the page?

    Thank you
  2. Eric Lawrence
    Admin
    Eric Lawrence avatar
    833 posts

    Posted 07 Oct 2014 Link to this post

    Do you actually need a regular expression, or are you simply searching for a string?

    if (oSession.oResponse.MIMEType.Contains("html")) {
      oSession.utilDecodeResponse();
      if (
    oSession.utilFindInResponse("jimmy", false)>-1)
      {
        //...
      }
    }


    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.

     
  3. nasekt
    nasekt avatar
    40 posts
    Member since:
    Aug 2014

    Posted 07 Oct 2014 in reply to Eric Lawrence Link to this post

    The problem is,  the Metadata collected from the previous visits gets listed as well, So there are 70-80 identical strings in a given HTML 


     <title>if the title contains the string jimmy, then block the page</title> 

    How can I do this with Fiddler?




Back to Top