Sam Sam - 1 year ago 45
Javascript Question

What Javascript Regular Expression features are unique to Javascript?

I hope this question isn't too broad, but then again I would expect the Javascript (and other languages) regular expression engine's to share most of it's functionality with what is considered standard / expected regular expression behavior.

I made a statement about C# having unique regular expression capabilities in this post :: RegEx match open tags except XHTML self-contained tags

Specifically, here is the statement:

C# is unique when it comes to regular expressions in that it supports
Balancing Group

I'm curious what unique regular expression capabilities javascript has if any.

Answer Source

Although JavaScript’s regular expression library supports features that are considered as common (see comparison table), there is one particular expression that I haven’t seen in other:


This matches any arbitrary character similar to /[\s\S]/ (or any other union of complementary character classes) and can be handy as JavaScript does not have a s modifier like others have to have . match line breaks too.

Similar to that:


This evaluates to an empty character set and can’t match anything at all.