Split two types of tags

Split two types of tags
0.0 0


My code generates tags.
For example:

  • hello
  • bye
  • ciao
  • bonjour (FR)
  • sayonara (JP)

With regex did I define those tags that have brackets (so these tags: “bonjour (FR)” and “sayonara (JP)” in above example.

Here the code (this code shows ALL tags):

if(tag.name.match(/[a-zA-Z0-9]+\s*\([a-zA-Z0-9]+\)/)) {
    '<a href="' + self.url_for(tag.path) + '" style="' + style + '">' +

What I want to achieve is:

  1. Show only those tags with the regex code that has “xxxxx (yy)”, “aaaa (bb)”. So the other ones NOT (for example, “hello”, “ciao”, etc.). = widget-one
  2. Show only those tags for which the regex does NOT apply, so these tags “hello”, “ciao”, etc. = widget-two.

I was messing around with .split but I could only split within the tag itself. Not between my “two types” of tags. How to do it?

haveBracket = []
doesntHaveBracket =[]

for tag in tags:
  if tag.name.match(hasTagRegex):