Regex: match a string in span tag
Posted: Tue Oct 07, 2014 10:19 am
I want to programmatically block a page, if a certain string is present in the title. The below code is JScript .NET, which is basically a .NET version of Javascript.
Basically, How do I tell Regex to find the string episode present in span tag; If found, then block the page?
Example:
<span id="eow-title" class="watch-title " dir="ltr" title="The monster truck show - episode 12">
<span id="eow-title" class="watch-title " dir="ltr" title=" Pt 1 Combat Shotgun Shootout: episode09">
Thank you
Code: Select all
var bodyString = oSession.GetResponseBodyAsString(); // oSession is a Fiddler object session
if (oSession.oResponse.MIMEType.Contains("html")) {
var regex = /NotYetComplete/;
var text = /NotYetComplete/
if (regex.test(text))
{
oSession.oRequest.FailSession (404, "Blocked", "Fiddler blocked product service request"); // Block the page
}
}
}Code: Select all
<span id="eow-title" class="watch-title " dir="ltr" title="............episode............"><span id="eow-title" class="watch-title " dir="ltr" title="The monster truck show - episode 12">
<span id="eow-title" class="watch-title " dir="ltr" title=" Pt 1 Combat Shotgun Shootout: episode09">
Thank you