Hi sahib,
First of all, this is NOT a basic question ... regexes are notoriously difficult to get to grips with. If you've got this far on your own as a newbie, then hat's off!
But I'm a little surprised that the function works as you'd expect. Consider the first pattern ...
url [ / url ] (I've put spaces in just so that the forum doesn't parse it as a hyperlink)
... applied to the text ...
[ url ]www.site1.com[ / url ] and [ url ]www.site2.com[ / url ]
In this case the bracketed match will be ...
www.site1.com[ / url ] and [ url ]www.site2.com
... and not what you might expect ...
www.site1.com
This is because the (.*) bit is 'greedy' ... it will find the largest match, not the 'first'.
I would change this to read (in full) ...
/[url]([[])[\/url]/ where (.) is now ([[]*).
BTW ([[]*) will match all chars until it meets a '['.
Secondly, I would understand how each individual match works before trying to apply an array of replacements. Doing seperate preg_replace() 's just takes up a few more lines and is much much easier to debug.
Hope that helps.
Paul 🙂