Issue
I want to validate whether the user enter data in this form B101,202,BBB,B902,Z-102 That is each value can be only of alphabets, digits or alphanumeric + '-' Tried this expression but it failed for alphabets and digits only condition. ^[A-Za-z0-9]+(,[A-Za-z0-9]+)*[A-Za-z0-9]+$
Solution
Please try the following regex
^[A-Z0-9]+((,|-)[A-Z0-9]+)*[A-Z0-9]+$
This checks the following:
- Starts with Alphabets or Numeric
- Ends with Alphabets or Numeric
You can try it online at Regexr.com
Answered By - Partha
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.