Re: What's wrong with this regular expression?

From: Date: Sat, 21 Jul 2001 04:09:23 +0000
Subject: Re: What's wrong with this regular expression?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-58988@lists.php.net to get a copy of this message
Hi James, This is what you want $body=eregi_replace ("<a href=\"([^>]+)\">([^<]+)</a>","[url=\"\\1\"]\\2[/url]",$body); You were checking for no ['s in the string instead of no >'s or <'s -------------------------------- - -- - - - Philip Murray - webmaster@open2view.com http://www.open2view.com - Open2View.com ------------- - -- - - ----- Original Message ----- From: "James Crowley" <james@vbweb.co.uk> To: "PHP List" <php-general@lists.php.net> Sent: Saturday, July 21, 2001 6:26 AM Subject: [PHP] What's wrong with this regular expression? > Hi, > Could someone please point out where I've gone wrong with this regular > expression...? > > $body="<a href=\"http://www.fred.com\">my > test</a> or <a > href=\"/show.asp?id=333\">here</a>"; > $body=eregi_replace ("<a > > href=\"([^\\[]*)\">([^\\[]*)</a>","[url=\"\\1\"]\\2[/url]",$body); > > #$body should now be > [url="http://www.fred.com"]my test[/url] or > [url="/show.asp?id=333"]here[/url] > #but instead, it is > [url="http://www.fred.com">my test</a> or > <a > href=\"/show.asp?id=333\"]here[/url] > echo $body; > > Thanks > > - James > > Editor, VB Web > ================== > Web - http://www.vbweb.co.uk > Email - james@vbweb.co.uk > ICQ# - 60612011 > Fax - +44(0)8707052859 > ================== > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#58988) next »