JavaScript Regex match all characters
JavaScript regular expressions (browser) do not have a modifier allowing the dot (.) to match all characters including the newline like the ’s’ modifier does for PERL and PCRE in PHP.
However a cool tip I learnt just recently is that using a character class and it’s negated version will allow you to match all characters. Eg: /[\s\S]/g will match all characters in a JavaScript Regular Expression.
I used this trick in the ASCII to Hex conversion JavaScript code I posted a few days ago and thought to mention it.
Related posts:
- ASCII to Hex in JavaScript This JavaScript will add a method to the String object, that converts the ASCII string to a hex string consisting...
- Base conversion in JavaScript I just realized recently that you can convert between number bases in JavaScript using the built in method Object.prototype.toString() and...