diff --git a/.babelrc b/.babelrc index 30db389..99259c8 100644 --- a/.babelrc +++ b/.babelrc @@ -4,8 +4,8 @@ [ "@babel/plugin-transform-runtime", { - "corejs": 3, - }, + "corejs": 3 + } ], "add-module-exports", "transform-xregexp", diff --git a/README.md b/README.md index c4a6cdd..9a91dcd 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,9 @@ [![Build Status](https://github.com/slevithan/xregexp/workflows/Node.js%20CI/badge.svg)](https://github.com/slevithan/xregexp/actions) +[](https://github.com/slevithan/awesome-regex) Included in
+[Awesome Regex](https://github.com/slevithan/awesome-regex) + XRegExp provides augmented (and extensible) JavaScript regular expressions. You get modern syntax and flags beyond what browsers support natively. XRegExp is also a regex utility belt with tools to make your grepping and parsing easier, while freeing you from regex cross-browser inconsistencies and other annoyances. XRegExp supports all native ES6 regular expression syntax. It supports ES5+ browsers, and you can use it with Node.js or as a RequireJS module. Over the years, many of XRegExp's features have been adopted by new JavaScript standards (named capturing, Unicode properties/scripts/categories, flag `s`, sticky matching, etc.), so using XRegExp can be a way to extend these features into older browsers. @@ -59,8 +62,8 @@ XRegExp.replace('2021-02-22', date, '$/$/$'); // -> '02/22/2021' XRegExp.replace('2021-02-22', date, (...args) => { // Named backreferences are on the last argument - const groups = args[args.length - 1]; - return `${groups.month}/${groups.day}/${groups.year}`; + const {day, month, year} = args.at(-1); + return `${month}/${day}/${year}`; }); // -> '02/22/2021' diff --git a/docs/api/index.html b/docs/api/index.html index c3765cb..3b4bb23 100644 --- a/docs/api/index.html +++ b/docs/api/index.html @@ -932,8 +932,8 @@

Example

// Regex search, using named backreferences in replacement function XRegExp.replace('John Smith', name, (...args) => { - const groups = args[args.length - 1]; - return `${groups.last}, ${groups.first}`; + const {first, last} = args.at(-1); + return `${last}, ${first}`; }); // -> 'Smith, John'