note 62305 deleted from function.ereg by tularis
| From: | tularis@php.net | Date: | Thu, 31 May 2007 13:22:42 +0000 |
| Subject: | note 62305 deleted from function.ereg by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-127061@lists.php.net to get a copy of this message | ||
Note Submitter: odnowa-sql at o2 dot pl
----
I would like to inform you about a bug-like thingy which I've seen when trying to convert
BBcode [url][/url] tags to HTML <a href=''></a> tag. This was my code:
$vn = ereg_replace("\\[url=([^\[]*)\\]([^\[]*)\\[/url\\]","<a href='http://\\1'>\\2</a>",$vn);
It looks a bit complicated, look closer at the following part of above line:
[^\[]
You will probably notice ONE backslash instead of two, but it really worked when I was trying to
match everything except [ character. And the [^\\[] sequence did not work. So, when you are placing
a negated bracket, escape it by ONE backslash.