As action code syntax eclipses older syntaxes there is some scope for confusion where regular expressions are used. In the new v5.7+ 'dot' operators, e.g. String.contains(pattern), one of the options for the 'pattern' parameter is a regex which needs to be quoted - enclosed in double quotes. This conforms to a general rule of thumb that anything that is a string (literal, template name, regex, etc.) should be quoted. This helps Tinderbox to detect where the parameter is actually an expression.
The exception to this is the long standing AttributeName(pattern) operator originally introduced as part of the query language; with this do not quote your regular expression. This operator should new be considered deprecated in favour of the $Attribute.contains(pattern) operator. Thus:
$MyString(\W+) (now deprecated)