I wan't to replace
[a href='url']link[/a]
to
<a href='url'>link</a>
I am using $line = str_replace("[a href='+(.*)+']", "<a href='+(.*)+' >", $line); is not working.
Why not just use:
$search = array('[', ']');
$replace = array('<', '>');
$line = str_replace($search, $replace, $line);
[] in the url or link it'll fail (by replacing too much)You have to use a regular expression to do this
$line = preg_replace('~\\[a +href=\'([^\']+)\'\\]([^\\[]+)\\[/a\\]~', '<a href="$1">$2</a>', $line);
newval = varname.replace(/\[a +href='([^']+)'\]([^\[]+)\[\/a\]/, '<a href="$1">$2</a>')This is a great tutorial http://www.youtube.com/watch?v=x9VLWlQhNtM it shows you how to make a small templating engine and it covers what your asking