Rewrite REGEX in IF statement

In below code I have REGEX.

This REGEX allows me to “filter-out” a specific type of “tags” I have.

For example… tag “Hello” is treated differently (in CSS styling) than tag “Ciao (IT)”.

This all works well, no problem there, all good.

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

In another file I have “IF” statement…

if (page.tag)
  do something

In above statement I need to incorporate my REGEX also, and I tried something like this:

if (page.tag(/[a-zA-Z0-9]+\s*\([a-zA-Z0-9]+\)/))
  do something

But that does not work.

Question is how to incorporate REGEX in above statement that makes it work?

i think you are missing either ‘match’ or ‘test’ depending on whether you want the matched result or not.
You can look up both those functions for how to use them.

Like @hbar1st asked, what exactly is your regular expression supposed to be checking for above? I assume you will need to use RegExp.prototyp.test, but not 100% sure until you reply back.