Please advice a regular expression to find all string which are not ended with ".pdf". So, it should find stings "some string" and "some stringpdf", but not the strings like "some string.pdf"
Thanks, Aleksey Asiutin
Please advice a regular expression to find all string which are not ended with ".pdf". So, it should find stings "some string" and "some stringpdf", but not the strings like "some string.pdf"
Thanks, Aleksey Asiutin
If you are going to test individual string's you can use this regex
/^(?!.*\.pdf$).*$/
If there are multiple string's to be matched within the string,you can use
/(\s|^)(?![^\s]+\.pdf(\s|$))[^\s]+/
here's the regex
/^(?!.*\.pdf$).*/
example:
var r = /^(?!.*\.pdf$).*/;
r.test("some string"); //true
r.test("some stringpdf"); //true
r.test("some string.pdf"); //false
in actually, I recommend the suggestion from @Nannuo Lei.