Fork me on GitHub

Get the fancy new XRegExp 2.0 Release Candidate and upgraded/new addons at GitHub! See the long list of changes and improvements in the Roadmap.

Download XRegExp 1.5.1 with comments, or grab the minified version (2.7 KB gzipped).

What is it?

XRegExp is an open source (MIT License) JavaScript library that provides augmented, extensible, cross-browser regular expressions. You get new syntax and flags beyond what browsers support natively, along with a collection of functions to make your client-side grepping and parsing a breeze. XRegExp also frees you from worrying about pesky inconsistencies in cross-browser regex handling.

XRegExp is fully compliant with the regular expression flavor specified in ES3 and ES5. It works with Internet Explorer 5.5+, Firefox 1.5+, Safari 3+, Chrome, and Opera 9.5+.

Check out some nifty usage examples ⇨.

Features

Performance

XRegExp regular expressions compile to native RegExp objects, thus there is little if any performance difference when using XRegExp objects with native regex methods. There is a small extra cost when compiling XRegExps. If you want, however, you can use XRegExp.cache to avoid incurring the compilation cost for a given pattern more than once. Doing so can even lead to XRegExp being faster than native regexes in synthetic tests that repeatedly compile the same regex.

Raves

XRegExp … is an impressive regular expression library that works in Node and even Internet Explorer 5.5.

XRegExp … does some killer stuff that the native JS RegExp does not … it's a must-have for grepping and/or parsing on the client side.

XRegExp adds more power to RegExp with features that will be part of the browsers of tomorrow.

Steve Levithan, once again, brings the JS RegExp smackdown.

For those of you so advanced in your RegEx powers that you've hit the limitations of the built-in JavaScript implementation, check out XRegExp, an open-source regular-expression library that supports named capture and other advanced features.

XRegExp … adds some amazing features to stock JS capabilities.

Are you using XRegExp in your projects? I'd be happy to hear about it.

Follow me @slevithan, on my blog, or at GitHub.

The world's greatest regex tester will be adding XRegExp 2 as a supported flavor in RegexBuddy 4 (coming soon).