RE: [PHP] Need help with a regex
| From: | esctoday.com | Wouter van Vliet | Date: | Sun, 21 Sep 2003 17:22:33 +0000 |
| Subject: | RE: [PHP] Need help with a regex | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-163361@lists.php.net to get a copy of this message | ||
Pretty easy, just make the regex stuff a little less greedy .. ;)
class='newsitemcontent-td' colspan=2>(.*?)<\/td><\/tr>/
That would catch it .. And yes, the question mark is both correct and
confusing. But it doesn't mean "maybe" in here. Now let's hope that your
post doesn't include <td></tr> ..
Wouter
Ps. I'm assuming you use perl compatible regexes (preg_*) and not POSIX
(ereg_*), don't know if this works for POSIX as well
-----Original Message-----
From: Adam Zey [mailto:guspaz@gus.ath.cx]
Sent: Sunday, September 21, 2003 7:07 PM
To: php-general@lists.php.net
Subject: [PHP] Need help with a regex
I'm using the following regex:
/<tr><td class='newsitemtitle-td'>([^<]*)<\/td><td
class='newsitemposter-td'><span
class=([^>]*)>([^<]*)<\/span>([^<]*)<\/td><\/tr> <tr><td
class='newsitemcontent-td' colspan=2>([^<]*)<\/td><\/tr>/
Everything works well, except I've ran into one problem. In the last text
field, the bulk of the newsitem, sometimes the poster includes some HTML
tags (Like "<br \>", but others could be inserted). What I need to do is
modify that last submatch "([^<]*)" so that instead of matching until it
reaches a "<" (It catches on the br tag and ruins the match), it will match
until it reaches the entire <\/td> tag. Can somebody help me out with this?
I'm completely stumped about how to go about doing a "match until string" as
opposed to a "match until character".
Regards, Adam.
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.520 / Virus Database: 318 - Release Date: 18/09/2003
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php