When you use the RegExp
construct, you need to double escape with your backslashes:
var rangeRegex = new RegExp("(\[|\])[0-9]+,([0-9]+(\[|\])|inf\])\s?.*");
Or use a literal one::
var rangeRegex = /([|])[0-9]+,([0-9]+([|])|inf])s?.*/;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…