Page 1 of 1

match string in html file

Posted: Fri Jun 04, 2010 4:12 pm
by playwright
Is there a way to search in html file for a specific string and the same string plus some other content? For example:
abc.php?t=123 and also abc.php?t=123&page=2 and abc.php?t=123&page=3. Is there a regex that can do the job along with preg_match()?

Re: match string in html file

Posted: Sat Jun 05, 2010 6:20 pm
by John Cartwright
Post the entire contents of your html. It is dificult to create the parameters without knowing the boundaries. For instance, most url's are enclosed in quotes, so a simple regex would like like

Code: Select all

preg_match('~(abc\.php[^"]+)~im', $htmlsource, $matches);
Which will capture any string beginning with abc.php until it reaches a double quote.