javascript - Match x, but not y anwywhere (not before, between or after the matching pattern) -


i want match several ways of writing lastname, not match firstname. how can done? have regex below, can't find "and not match 'first' anywhere" (so neither logical , or logical not).

(?:(?:(?:last)*.*name)|(?:name.*last)|(?:(?:achter)*.*naam)|(?:familie.*naam)

but since "name" means lastname, match firstname don't want. tried adding, failed with, expressions this: [^(?:first)]+, (?!(?:first)), etc.

p.s. don't have libarty of using javascript functions or anything. have put regex field of form of firefox autofill-addon. so, need solve within regex itself.

to match not contain first , not empty:

^(?:(?!first).)+$ 

if has contain name:

^(?:(?!first).)*name(?:(?!first).)*$ 

you use 2 checks:

(str.search(/name/i) >=0 && str.search(/first/i) == -1) 

Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -