posted 16 years ago
I have one problem about JavaScript regular expression which does not work as what I want.
User has reqirement as following:
W = Alpha/Numeric (No Blank)
Y = Alpha/Blank
Z = Numeric/Blank
Now user required the field must match mask:WWWWWYZ, which means
The match value for this should be "12345","12345A", or "12345A9"
or "12345 (2 spaces)","12345A (1 space)", or "12345A9"
I translated the mask to the following javaScript regular expression:
"[a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9]([a-z]|(\s*))([0-9]|(\s*))"
However, this regular expression match value for "1234567", this should not happen.
If you change regular expression to ]"[a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9]([a-z]|(\s+))([0-9]|(\s+))", then "12345" could not match.
Anyone in this forum can help me with this? This is really urgent for our project, which is cutting off soon.
Thanks in advance.
Sam
Yours Sam<br />SCJP5.0 97%<br />SCBCD5.0 72%