I've got two related URL matching patterns, one of which works, and the other which works only in regex testers, but not in JS itself.
Pattern 1: match Rails index URL (works)
var pattern = '(?!.*\/items\/.*).*\/items';
var re = new RegExp(pattern);
re.test('/my/items');
=> true
https://regex101.com/r/oO5wJ0/1 (tester matches)
https://jsfiddle.net/x9avvxdc/ (js matches)
Pattern 2: match Rails single resource URL (works in regex tester, not in JS)
var pattern = '(?!.*\/items\/.*\/).*\/items\/\d+';
var re = new RegExp(pattern);
re.test('/my/items/8');
=> false
https://regex101.com/r/bF1rU9/1 (tester matches)
https://jsfiddle.net/k4ownsky/ (js doesn't match)
Not sure what the problem is with number 2...