I have this replace code to parse BB code and convert links to clickable hyperlinks. This works for one link, however if there is more than one link in the string, it merges them together in one long link, hyperlinking all text in between. I thought the [g] flag accounted for this, but doesn't appear to work.
about = about.replace(/\[url=([^\s\]]+)\s*\](.*(?=\[\/url\]))\[\/url\]/g, '<a href="$1" target="_blank">$2</a>')
I worked it out with the following:
about = about.replace(/\[url=([^\]]+)\](.*?)\[\/url\]/gi, "<a href=\"$1\" target=\"_blank\">$2</a>")