javascript - Regex error in Netbeans not present in other editors -


i have following regular expression works fine in application code , other code editors have not reported problem it. used validate password.

/^(?=.*[a-za-z])+(?=.*[\d])+(?=.*[^a-za-z\d\s])+.*$/ 

so in other words:

must have 1 letter must have 1 digit must have 1 non-letter, non-digit

now seems netbeans has decent regex parser , has reported erroneous statement. new regex cannot spot error. due using positive lookahead ?= 1 or more + @ end?

when take out + error goes away, regex stops performing in application.

if can tell me wrong expression great.

the statement used in jquery validation plugin use, if helps. due fact using plugin, prefer not splitting several smaller (clearly simpler , cleaner) expressions. require great deal of work.

it never makes sense apply quantifier zero-width assertion such lookahead. whole point of such assertions allow assert condition true, without consuming of text--that is, advancing current match position. regex flavors treat syntax error, while others ignore quantifier. getting rid of plus signs makes regex correct:

/^(?=.*[a-za-z])(?=.*\d)(?=.*[^a-za-z\d\s]).*$/ 

if doesn't work expected, may running the infamous ie lookahead bug. usual workaround reorder things first lookahead anchored @ end, so:

/^(?=.{8,15}$)(?=.*[a-za-z])(?=.*\d)(?=.*[^a-za-z\d\s]).*/ 

the (?=.{8,15}$) example; have no idea real requirements are. if want impose minimum , maximum length limits, ideal place it.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -