'[b]one[/b] two [b]three[/b]'.replace( /\[b\](.*)\[\/b\]/, '<b>$1</b>' );
But such a replacement would be nice since there is no need to check for HTML validity then. Unclosed markups will stay simple text.
You can use
+ to make it ungreedy, e.g.
I'm late, but I'll post the regex anyway.
'[b]one[/b] two [b]three[/b]'.replace( /\[b\](.+?)\[\/b\]/g, '<b>$1</b>' );
©2020 All rights reserved.