Re: REGULAR EXPRESSION HELP
| From: | John W. Holmes | Date: | Sat, 12 Jul 2003 16:39:33 +0000 |
| Subject: | Re: REGULAR EXPRESSION HELP | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-154958@lists.php.net to get a copy of this message | ||
John wrote:
I need to match a pattern, not in a single-line but from a HTML page, which obviously has loads of lines. I need to match 2 lines from this HTML page: 1) <HTML><TITLE>FirstVariable - Second Variable</TITLE></HTML>........ 2) <TABLE><TD><TR>(newline) ThirdVariable</TR></TD></TABLE>... I tried this code: 1) preg_match("/<HTML><TITLE>(\S+) - (\S+)</TITLE></HTML>/", $html_page, $variables); 2) preg_match("/<TABLE><TD><TR>\n(\S+)</TR></TD></TABLE>/", $html_page, $variables); The first 2 variables are matched into the $variables array but not the third one. Sometimes when the third one is matched, it starts from where I want it to start but takes all the text to the end of the HTML document!Your "newline" may be \r\n or \r instead of just \n. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ PHP|Architect: A magazine for PHP Professionals – www.phparch.com