Re: Need help with a regex
| From: | Adam Zey | Date: | Sun, 21 Sep 2003 17:48:11 +0000 |
| Subject: | Re: Need help with a regex | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-163364@lists.php.net to get a copy of this message | ||
Thanks, that did the trick :)
Only thing was I had to modify it for newline support:
<tr><td class='newsitemtitle-td'>([^<]*)<\/td><td
class='newsitemposter-td'><span
class=([^>]*)>([^<]*)<\/span>([^<]*)<\/td><\/tr> <tr><td
class='newsitemcontent-td' colspan=2>((.|\n)*?)<\/td><\/tr>
Regards, Adam.
"Esctoday.Com | Wouter Van Vliet" <wouter@esctoday.com> wrote in message
news:20030921172226.95E2C77B8B@smtp6.wanadoo.nl...
> 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
---
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