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.
You can use this regex to make sure your match doesn't end with .js
:
^(?!.+\.js$).+$
(?!.+\.js$)
is a negative lookahead condition to fail the match if line has .js
at the end.