zloirock/core-js

[RegExp] Lookbehind assertion

Open

#876 geöffnet am 27. Okt. 2020

Auf GitHub ansehen
 (4 Kommentare) (11 Reaktionen) (0 zugewiesene Personen)JavaScript (1.609 Forks)batch import
enhancementeshelp wanted

Repository-Metriken

Stars
 (23.771 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

Does core-js provide a way to polyfill the RegExp feature Lookbehind assertion not available in IE11?

This example uses look-behind and works in Chrome but not in IE11 (as is to be expected):

// replaces image aspect ratio in image URL:
// <...anything...>/893476/default/cute_kittens.jpg
// <...anything...>/893476/image4_3/cute_kittens.jpg
// <...anything...>/893476/square-big/hq/cute_kittens.jpg
// <...anything...>/893476/landscape.small/cute_kittens.jpg
url.replace(/(?<=[/][0-9]+[/])[a-z0-9._-]+(?=([/]hq)?[/][^/]+\.[^./]+$)/i, aspectRatio);

My project is configured to use babel and automatically add core-js polyfills for all used ES6 features:

presets: [
                [
                  "@babel/preset-env",
                  {
                    modules: false,
                    targets: {
                      browsers: ["last 2 versions", "ie >= 11"]
                    },
                    useBuiltIns: 'usage',
                    corejs: '3',
                  }
                ],
                "@babel/preset-typescript",
                "@babel/preset-react",
              ]

Contributor Guide