I want to replace something like [link=http://www.site.com]Go here![/link]
with <a href="http://www.site.com">Go here!</a>
Can I do that with Regular Expressions?
Find & Replace
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
yes. I'm pretty sure I posted the code for it a while ago in here somewhere....
well.. if you look at phpbb's bbcode.php file in the include folder, you'll find the info packed in there... There was a half-decent evilwalrus bbcode thing, but since the server is in limbo... you may be able to snag it via google cache or something.
well.. if you look at phpbb's bbcode.php file in the include folder, you'll find the info packed in there... There was a half-decent evilwalrus bbcode thing, but since the server is in limbo... you may be able to snag it via google cache or something.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Code: Select all
$string = '[link=http://www.site.com]Go here![/link]';
$anchor = preg_replace('/\[link=([^\]]+)\]([^\[]+)\[\/link\]/i', "<a href=\"$1\">$2</a>", $string);