Re: [PHP] Regex pattern for preg_match_all

2011-02-22 Thread Yann Milin
Le 19/02/2011 0:23, Tommy Pham a écrit : @Simon, Thanks for explaining about the [^href]. I need to read up more about greediness. I thought I understood it but guess not. @Peter, I tried your pattern but it didn't capture all of my new test cases. Also, it captures the single/double quotes

Re: [PHP] Regex pattern for preg_match_all

2011-02-18 Thread Tommy Pham
@Simon, Thanks for explaining about the [^href]. I need to read up more about greediness. I thought I understood it but guess not. @Peter, I tried your pattern but it didn't capture all of my new test cases. Also, it captures the single/double quotes in addition to the fragments inside the hre

Re: [PHP] Regex pattern for preg_match_all

2011-02-18 Thread Peter Lind
On 18 February 2011 22:36, Tommy Pham wrote: > Hi folks, > > This is not directly relating to PHP but it's Friday so I'm gonna give > it a shot :).  Would someone please help me figure out why my regex > pattern doesn't work.  Below is the code and sample data: > > $html = << href="http://images.

Re: [PHP] Regex pattern for preg_match_all

2011-02-18 Thread Simon J Welsh
As far as I can tell, your problem lies in [^href]*. That will match any characters other than h, r, e or f, not anything other than the string href. Consider replacing it with [^>]*?. The ? makes it non-greedy so it will stop as soon as it can (when it matches the first href) rather than as lat

[PHP] Regex pattern for preg_match_all

2011-02-18 Thread Tommy Pham
Hi folks, This is not directly relating to PHP but it's Friday so I'm gonna give it a shot :). Would someone please help me figure out why my regex pattern doesn't work. Below is the code and sample data: $html = <Images ht