javascript - NOT a specific word at ending in regex -


i have strings:

"/page/test/myimg.jpg" "/page/test/" "/page2/test/" "/page/test/other" 

i want true strings starting /page/test except when ends .jpg.

then did: /^\/page\/test(.*)(?!jpg)$/. well, it's not working. :\

it should return this:

"/page/test/myimg.jpg" // false "/page/test/" // true "/page2/test/" // false "/page/test/other" // true 

use negative behind anchored end:

/^\/page\/test(.*)(?<!\.jpg)$/ 

for clarity, regex match input *doesnt end in .jpg:

^.*(?<!\.jpg)$ 

edit (now must work in javascript too)

javascript doesn't support behinds, ugly option must used, says @ least 1 of last 4 characters must other .jpg:

^.*([^.]...|.[^j]..|..[^p].|...[^g])$ 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -