1

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 Definitions.

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

Community
  • 1
  • 1
Sam
  • 26,946
  • 12
  • 75
  • 101

4 Answers4

4

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.

Gumbo
  • 643,351
  • 109
  • 780
  • 844
2

JavaScript's regex engine is merely a subset of Perl's engine, meaning that it doesn't add anything new and is missing many of the features Perl contains.

You can read more about it here: http://www.regular-expressions.info/javascript.html.

Ryan Berger
  • 9,644
  • 6
  • 44
  • 56
2

javascript regexes are a subset of perl regexes.
Meaning, it has no unique features, but it's missing quite a few.

2

Javascript regular expressions are modeled on Perl's regular expressions.

See: http://www.regular-expressions.info/javascript.html

kitti
  • 14,663
  • 31
  • 49