Page 1 of 1

working from the inside out

Posted: Tue Aug 05, 2008 3:56 pm
by HiddenS3crets
I have the following regex comparison that replaces any [*]content[/*] with <*>content</*>

Code: Select all

<?php
$pattern = "/\[link\=(.+?)\](.+?)\[\/link\]/is";
$replacement = "<a href=\'$1\'>$2</a>";
?>
I was wondering if there's a way to modify this code so it will match when you do multiple tags such as: [*][*]content[/*][/*] so it will convert both sets of [] with <>

Re: working from the inside out

Posted: Tue Aug 05, 2008 4:15 pm
by prometheuzz
You mean you want to replace a String like:

Code: Select all

[ b][link="http://www.google.com"]Google[/link][ /b]
with

Code: Select all

<b><a href="http://www.google.com">Google</a></b>
where all kind of html tags and attributes can be used, then the answer is: no, there is no easy way to do this with regex.