Forum Moderators: coopster

Message Too Old, No Replies

PHP Regular expression functions

         

thing3b

11:42 am on May 12, 2005 (gmt 0)

10+ Year Member



I have been using the "preg_match_all" function in PHP to find text that matches my regular expression.

The php website documentation for "preg_match_all" states that "After the first match is found, the subsequent searches are continued on from end of the last match."

The problem is that I want all possible matches, and do not want it to "start the subsequent searches from the end of the last match".

Does any one know how I can achieve this?

ergophobe

3:33 pm on May 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This is inherent in regular expressions. Essentially, they only backtrack when they fail. You can get them to fail at an earlier point using lookaheads, but I don't think that will solve your problem.

Can you give a short example of some text you would search in to show the situation where it currently fails to meet your needs and then say what you would want to see actually matched?