Looks like it is not first question about look-behind, but I didn't find an answer.
Javascript has no (positive|negative)look-behind requests.
I need a regular expression that match *.scss file name, but didn't match the names like *.h.scss. With look-behind request is looks like:
/(?<!(\.h))\.scss$/
How can I do this in javascript? I need this regular expression for webpack rules "test" parameter, so the javascript regex required only.
You may use
/^(?!.*\.h\.scss$).*\.scss$/
See the regex demo
Details
^
- start of string anchor(?!.*\.h\.scss$)
- a negative lookahead failing the match if the string ends with .h.scss
.*
- any 0+ chars as many as possible\.scss
- a .scss
substring at the...$
- end of the string.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With