PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Thu Sep 21, 2017 8:55 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Tue Oct 07, 2014 10:19 am 
Offline
Forum Newbie

Joined: Wed Jul 30, 2014 4:06 pm
Posts: 7
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.

Syntax: [ Download ] [ Hide ]
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
                        }
                    }
                }


Basically, How do I tell Regex to find the string episode present in span tag; If found, then block the page?


Syntax: [ Download ] [ Hide ]
<span id="eow-title" class="watch-title  " dir="ltr" title="............episode............">


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


Top
 Profile  
 
PostPosted: Tue Oct 07, 2014 11:32 am 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13427
Location: New York, NY, US
Use preg_match(). You will need to use ungreedy matches, so broken down you would search for '<span ' then '.*?' then 'title="' then '.*?' then 'episode' then '.*?' then '>'.

_________________
(#10850)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group