4 ms·
In JS you can comment regular expressions, too... :) var foo = new RegExp( '\\d\+' + // First digit '-' + // Deli
by phuff 15y ago
In JS you can comment regular expressions, too... :)
var foo = new RegExp(
'\\d\+' + // First digit
'-' + // Delimiter
'\\d\+' // Second digit
);
foo.test("1234-5432");
- elijahmanor 15y agoTrue, but then you have the overhead of string concatenation... although in the large scheme of things that is probably very small, unless you are doing it in a huge loop, but then you'd cache that RegExp anyway.
- natrius 15y agoConcatenation of string literals can be compiled away.