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.
Comments
Post a Comment