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