note 62305 added to function.ereg
| From: | odnowa-sql at o2 dot pl | Date: | Fri, 24 Feb 2006 18:28:02 +0000 |
| Subject: | note 62305 added to function.ereg | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-104375@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 195.136.184.34
Probable Submitter: 84.10.114.232
----
Manual Page -- http://www.php.net/manual/en/function.ereg.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+62305
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+62305&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+62305&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+62305&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+62305&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+62305&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+62305&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+62305&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+62305&report=yes
Search -- http://master.php.net/manage/user-notes.php