Flagrant Badassery

A JavaScript and regular expression centric blog

XRegExp 3.0.0!

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 by XRegExp.install/uninstall.
  • Removed the Prototypes addon, which added methods apply, call, forEach, globalize, xexec, and xtest to XRegExp.prototype. These were all just aliases of methods on the XRegExp object.
  • A few changes affect custom addons only: changed the format for providing custom Unicode data, replaced XRegExp.addToken’s trigger and customFlags options with new flag and optionalFlags options, and removed the this.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!

There Are 6 Responses So Far. »

  1. 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 ?

  2. 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!


  3. I really enjoy the article.Really thank you!

  4. Zelorra/a is India’s largest cost-effective online platform with engaging millions of people. The firm utilizes in-house technology to take care of entire products covering wide range of Seller Services and tools that help creative entrepreneurs start, manage and scale their businesses. With having a network of more than thousands of online partners stores we have established a world-class position as per the Indian Market strategies. Our mission is to renovate online shopping  that constructs a more fulfilling and lasting world. Online SHopping Site/a Download Zelorra App Now DOWNLOAD ZELORRA APP NOW/a We’re committed to using the power of business to strengthen communities and empower people.Zelorra Vendor Marketplace (B2B)Zelorra.com is a B2B2C Marketplace. We provide the tools & services to help you expand into new markets and connect with business buyers all around INDIA. An Indian community of Buyers & Sellers. Shipping labels you can print at home, with big discounts on postage. Seller protection and customer support to help you sell your stuff. We are committed to 24×7 for Every seller & buyer for their help with support & Education knowledge.It Takes no fees to start your Business JourneyIt doesn’t cost a thing to list up to infinite items and you only pay after your stuff sells. It’s just a small percent of the money we earn /a

  5. wonderful article really enjoyed

  6. Great Article

Post a Response

If you are about to post code, please escape your HTML entities (&, >, <).