When the `runtime` flag is on (by default), this plugin adds a new helper which wraps the native `RegExp` class to provide groups support. People nees to use a polyfill (I implemented it in core-js) for browsers that don't support ES6 regexps.
6 lines
159 B
JavaScript
6 lines
159 B
JavaScript
var re = /(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/;
|
|
|
|
var result = "2015-10-31".replace(re, "$<day>/$<month>/$<year>")
|
|
|
|
expect(result).toBe("31/10/2015");
|