sindresorhus / semver-regex

Regular expression for matching semver versions
MIT License
142 stars 33 forks source link

Lookbehind is not supported in all browsers (Safari) #20

Open bartversluijs opened 3 years ago

bartversluijs commented 3 years ago

Hi all,

First of all, thanks for this package! I'm using it to check the version input in a Vue.js frontend. However, when opening a page in Safari (the new Internet Explorer), a lookbehind in regex is not supported.

I'll try and change the Regex so it'll work in Safari. However, like most developers, regex is a "hocus-pocus language", especially when they're long like this one.

Any suggestions are welcome!

fregante commented 3 years ago

Bad news, Safari 15 doesn’t support it either https://caniuse.com/?search=regexp%20lookbehind

dzikoysk commented 2 years ago

Same for us:

obraz

Page stays blank then, so it's pretty much unusable in any app that has to support all browsers.

antongolub commented 2 years ago

Just a suggestion: you can check the input size first and then apply semver "official" regex. There're no lookbehinds so it may be more suitable.

The key profit of lookbehind here is the redos-safe assertion that .a.b.c meta follows after -foo.bar.etc. Old good -(...*(\. ...* (+ ...*)?)?)?-based approach might significantly affect performance.