After 3+ years, XRegExp 3.0.0 has been released. Standout features are dramatically better performance (many common operations are 2x to 50x faster) and support for full 21-bit Unicode (thanks to Mathias Bynens). I’ve also just finished updating all the documentation on xregexp.com so go check that out. 🙂
If you haven’t used XRegExp before, it’s an MIT licensed JavaScript library that provides augmented (and extensible!) regular expressions. You get new modern syntax and flags beyond what browsers support natively. XRegExp is also a regex utility belt with tools to make your client-side grepping and parsing easier, while freeing you from worrying about pesky cross-browser inconsistencies and things like manually manipulating lastIndex
or slicing strings when tokenizing.
Version 3.0.0 has lots of additional features, options, fine tuning, cross-browser fixes, some new simplified syntax, and thousands of new tests. And it still supports all the browsers. Check out the long list of changes. There are a few minor breaking changes that shouldn’t affect most people and have easy workarounds. I’ve listed them all below, but see the full changelog if you need more details about them.
XRegExp.forEach
no longer accepts or returns its context. Use binding with the provided callback instead.- Moved character data for Unicode category
L
(Letter
) from Unicode Base to Unicode Categories. This has no effect if you’re already using Unicode Categories or XRegExp-All. - Using the same name for multiple named capturing groups in a single regex is now a
SyntaxError
. - Removed the
'all'
shortcut used byXRegExp.install
/uninstall
. - Removed the Prototypes addon, which added methods
apply
,call
,forEach
,globalize
,xexec
, andxtest
toXRegExp.prototype
. These were all just aliases of methods on theXRegExp
object. - A few changes affect custom addons only: changed the format for providing custom Unicode data, replaced
XRegExp.addToken
’strigger
andcustomFlags
options with newflag
andoptionalFlags
options, and removed thethis.hasFlag
function previously available within token definition functions.
You can download the new release on GitHub or install via npm. I’d love to hear feedback and common regex-related use cases that you think could be simplified via new XRegExp features. Let me know here or in GitHub issues. Thanks!