Results 1 to 2 of 2
Feb 27, 2009, 03:51 #1
- Join Date
- Feb 2009
- 0 Post(s)
- 0 Thread(s)
Reg Expression Challenge - non-greedy type expression
I am ready to bang my head against the wall trying to figure out a solution for my needs. Any help would be greatly appreciated by a regex expert.
What I'm trying to do is match a specific set of content within some tags. Take the example below where i want to match the "content3" within the tag <href=" and STUFF_3
I cannot for the life of me figure out a way to structure a regex that'll capture that. Anything I do goes back to the longest match and non-greedy doesn't work.
Any help please?
Feb 27, 2009, 05:17 #2PHP Code:
$subject = '<href="content1">STUFF_1<href="content2">STUFF_2<href="content3">STUFF_3';
preg_match('/<href="([^"]+)">STUFF_3/', $subject, $matches);
Software Developer and PHP Manual Author.