Please help with this regex

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I have a text box on a form and I am validating the data(street address)
with the following expression
^[a-zA-Z\d]+(([\'\,\.\- #][a-zA-Z\d ])?[a-zA-Z\d]*[\.]*)*$.

The following address works excellent
23-89 New Street
1 south william street

The problem is I try puting "N'Select" and that was passed instead of fail.
Can anyone tell me why is my expression passing this?

Thanks
 
Chris said:
I have a text box on a form and I am validating the data(street address)
with the following expression
^[a-zA-Z\d]+(([\'\,\.\- #][a-zA-Z\d ])?[a-zA-Z\d]*[\.]*)*$.

The following address works excellent
23-89 New Street
1 south william street

The problem is I try puting "N'Select" and that was passed instead of fail.
Can anyone tell me why is my expression passing this?

"N" matches "^[a-zA-Z\d]+".
"'S" matches "([\'\,\.\- #][a-zA-Z\d ])?".
"elect" matches "[a-zA-Z\d]*[\.]*".
 
Back
Top