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 - [EMAIL PROTECTED]
http://www.open2view.com - Open2View.com
------------- -  -- -   -


----- Original Message -----
From: "James Crowley" <[EMAIL PROTECTED]>
To: "PHP List" <[EMAIL PROTECTED]>
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 - [EMAIL PROTECTED]
> ICQ#  - 60612011
> Fax   - +44(0)8707052859
> ==================
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to