The ?! n quantifier matches any string that is not followed by a specific string n.
In JavaScript, you can write RegExp patterns using simple patterns, special characters, and flags. In this section, we'll explore the different ways to write regular expressions while focusing on simple patterns, special characters, and flags.
The \ is known as the escape code, which restore the original literal meaning of the following character. Similarly, * , + , ? (occurrence indicators), ^ , $ (position anchors) have special meaning in regex. You need to use an escape code to match with these characters.
JavaScript RegExp test() The test() method tests for a match in a string. If it finds a match, it returns true, otherwise it returns false.
This has been driving me nuts. I'm trying to match everything that doesn't end in .js
. I'm using perl
, so ?<!
etc. is more than welcome.
mainfile
jquery.1.1.11
my.module
mainfile.js
jquery.1.1.11.js
my.module.js
This should be an insanely simple task, but I'm just stuck. I looked in the docs for both regex
, sed
, perl
and was even fiddling around for half an hour on regexr. Intuitively, this example (/^.*?(?!\.js)$/
) should do it. I guess I just stared myself blind.
Thanks in advance.
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