How can I test a string if it begins with “files/” and/or ends with “.js”?
Examples:
- test/test2/test.html –> true
- files/test2/test.html –> false
- test/test2/test .js –> false
- files/test2/test .js –> false
So far I have this regular expression: (^(?!files\/)).*?((?!\.js)$)
This works for “files/” but not for “.js”.
Edit:
Sorry for the misunderstanding. The string should only match if a string does NOT start with “files/” and does NOT end with “.js”.
Your last negative should be a look behind not a look ahead, At the point of the test you’ve already read the
.js