[thelist] PHP Regular Expression Dilemma

Simon Coggins ppxsjc1 at unix.ccc.nottingham.ac.uk
Tue Mar 6 09:30:34 CST 2001


Hi,

I'm trying to use regular expressions in PHP to strip anchor tags which
contain the "javascript:" statement. I've managed to get it working in
most cases, but if further tags are nested inside my anchors it all goes
wrong. The expression I'm currently using is:

$Description =
eregi_replace("<a[^<]*javascript:[^>]*>([^<]*)</a>","\\1",$Description);

and I've put a demonstration online at:

http://members.evolt.org/astro38/lab/regexp.php

I can see *why* it's happening, but I can't figure out what I can do about
it.

The problem is the ([^<]*) part - I need to make this say "any text until
you reach the next "</a>" statement.

Ideas anyone?

TIA

Simon








More information about the thelist mailing list