Why's my RegExp.test locking up?
Hi all,
I have the following Regular Expresion I'm running in InDesign to compare layer names to certain tagging. The script is freezing on this string:
var sizerx = /^(Y|W)?\d?X?(L|M|S|T)( |-)+?(Master)?$/g;
var str = "Women's 1/4 Zipper Guidelines - DO NOT TOUCH";
alert(sizerx.test(str));
I'm checking the layers to see if they match the following kinds of codes, all of which return true with the above regex:
- 3XS - Master
- 2XS
- XL Master
- YM - Master
- etc.
I've tried stripping out the slash marks and apostrophes before testing with:
.replace(/[^a-zA-Z0-9\- \.]/gi,"");
To no avail. Is my regex too greedy? A more elegant way to write it? I will admit to regex not being my strong suit, but standard ECMA6 regex finders online successfully return false for the given str variable above. Thanks in advance.

