in reply to Regex isn't performing like I think it should
I tried that against a portion of your example string (after replacing the <'s and >'s), and it seemed to work ok. I'm pretty much a newbie, so I imagine there are better ways to do it then I have described. Edit: By the way, it's the "g" option on the regex that makes it work in that "while". I guess when it tries to do a multiple match, it will eventually fall off the end, and return a false. Without the "g", that while statement I used will run forever, as long as the string contains a single match to your regexp.while ( $string =~ m!(<a[^>]*>)(.+?</a[^>]*>)!ig ) { print "$1 \n"; print "$2 \n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Regex isn't performing like I think it should
by Popcorn Dave (Abbot) on Jun 12, 2002 at 04:44 UTC | |
by jmarshall99 (Acolyte) on Jun 12, 2002 at 04:57 UTC | |
by Bird (Pilgrim) on Jun 12, 2002 at 22:13 UTC | |
by Popcorn Dave (Abbot) on Jun 12, 2002 at 22:21 UTC | |
|
Re: Re: Regex isn't performing like I think it should
by dsheroh (Monsignor) on Jun 12, 2002 at 16:46 UTC |