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!
Hi!
Just started having a look at v3.1.1.
Isn’t it possible to load xregexp and only a few addons without using NPM, Node.js nor RequireJS ?
Cheers!
Hi there!
I’m looking for a nodeJS module that would run regexes but that would limit the number of tries (in case of catastrophic backtracking). I don’t know if something like this exists in NodeJS like it exists in other languages.
Please let me know if you know something!
Thanks!