In Java script, regex expressions are surrounded by forward slashes (/). You're problem is you haven't closed off the regex or have enclosed the regex in quotes making the whole thing (including the regex declaring forward slashes) a string. In the API script editor, you might notice that your entire line is yellow after the start of your regex. This is the syntax you want: str.match(/\(\d+ turns\)/); This will match the text (4 turns) . If you want to use regex flags (e.g, global), add them after the closing forward slash: str.match(/\(\d+ turns\)/igm); Note that I removed an escape you had in there for your space. There's no real reason to escape a basic space. What you could do though is look for any number of whitespace to make it more flexible: str.match(/\(\d+\s+turns\)/igm); Edit: also, I'm not sure what your exact goal is for this match is, but I've found that .match is not terribly useful. If testing for text in a string I find /\(\d+\s+turns\)/igm.test(str) much more useful. If you're looking to replace or iterate through matches and do something with them, then I typically like to use str.replace(/\(\d+\s+turns\)/igm,"") . You can use a callback function instead of the string in the second argument of .replace.