[thelist] PHP Regular Expression Dilemma

Simon Coggins ppxsjc1 at unix.ccc.nottingham.ac.uk
Tue Mar 6 10:41:14 CST 2001


> > $Description =~ /<a[^<]*javascript:.*?>(.*)?</a>/si;
> 
> The problem is that .*? doesn't work with the PHP ereg functions. You will
> need to move to the preg_ fucntions in order to get non-greedy matching.

That seems to be the answer - before when I tried (.*)</a> it would
match the last </a> in the expression, not the next one.

> My tip for new PHP coders out there is to forget the ereg_ fucntions and use
> the pcre functions exclusively.

Okay I'll take a look, thanks everyone!

Simon






More information about the thelist mailing list