Javascript Regex "ends with" vs "does not end with" -


the following javascript renders boolean each statement's right:

var reg = new regexp(/^[\w\/].*result\b/);  console.log(reg.test('pathtofiletest')); -> false console.log(reg.test('path/to/file/test')); -> false console.log(reg.test('/path/to/file//test/result')); -> true console.log(reg.test('/path/to/file/not_a_test$#%$5724')); -> false 

which great! that's want. want invert ending statement. want other strings do not end in result true, while statement does end in result false. but, can't negate statement. i've tried:

^[\w\/].*^result\b ^[\w\/].*(?!result\b) ^[\w\/].*^(?!result\b) ^[\w\/].^(result\b) 

among ton of others. missing?

application curious

the reason i'm asking because i'm using express nodejs. call

router.get('/pathstring', function (req, res, next) {     //code } 

the pathstring regex expression. not true or false.

something should work

^(?!.*result$).*$ 

https://regex101.com/r/jo9fn6/1


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -