Ad

In this kata you should find BB-tags (bulletin board tags) in given string.

BB-tags look like:

[B]Some content[/B],

where [B] - opening tag and [/B] - closing tag.

Name of tags also can be lowercase:

[url]Some content[/url]

And BB-tags can be nested into each other, for example:

[url][b][size=5][color=blue]Some content[/color][/size][/b][/url]

If there is nested BB-tags, you should return only the outer tag with all it's content (with another tags into it).

function test(str) {
  return (str.match(/\[([a-zA-Z]+)](.*)\[\/\1]/g)).join('');
}