Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RegExp] Lookbehind assertion #876

Open
teetotum opened this issue Oct 27, 2020 · 4 comments
Open

[RegExp] Lookbehind assertion #876

teetotum opened this issue Oct 27, 2020 · 4 comments

Comments

@teetotum
Copy link

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",
              ]
@precious-void
Copy link

I'm wondering if this gist can help somehow?
https://gist.github.com/slevithan/2387872

@zloirock
Copy link
Owner

Yep, it could be useful.

@zloirock zloirock changed the title core-js polyfill for RegExp Lookbehind assertion? (needed for IE11) [RegExp] Lookbehind assertion Jun 8, 2021
@abhijith94
Copy link

Just wondering if this was implemented in core-js ?

@zloirock
Copy link
Owner

@abhijith94 as you can see, this issue contains a help wanted label. I do not plan to write this polyfill shortly. If someone wanna work on it, I'm ready to help and accept a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants