Skip to content

Commit d90bb0a

Browse files
committed
Tweaks
1 parent 85b6aba commit d90bb0a

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

.babelrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
[
55
"@babel/plugin-transform-runtime",
66
{
7-
"corejs": 3,
8-
},
7+
"corejs": 3
8+
}
99
],
1010
"add-module-exports",
1111
"transform-xregexp",

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
[![Build Status](https://github.com/slevithan/xregexp/workflows/Node.js%20CI/badge.svg)](https://github.com/slevithan/xregexp/actions)
44

5+
[<img align="left" src="https://github.com/slevithan/awesome-regex/raw/main/media/awesome-regex.svg" height="45">](https://github.com/slevithan/awesome-regex) <sub>Included in</sub><br>
6+
<sup>[Awesome Regex](https://github.com/slevithan/awesome-regex)</sup>
7+
58
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.
69

710
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, '$<month>/$<day>/$<year>');
5962
// -> '02/22/2021'
6063
XRegExp.replace('2021-02-22', date, (...args) => {
6164
// Named backreferences are on the last argument
62-
const groups = args[args.length - 1];
63-
return `${groups.month}/${groups.day}/${groups.year}`;
65+
const {day, month, year} = args.at(-1);
66+
return `${month}/${day}/${year}`;
6467
});
6568
// -> '02/22/2021'
6669

docs/api/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -932,8 +932,8 @@ <h3>Example</h3>
932932

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

0 commit comments

Comments
 (0)