vb.net - Regex to check if string is alphanumeric separated by commas or a single alphanumeric string -


i have following right works fine if string alphanumeric , separated commas, doesn't work if have single string.

"^([a-za-z0-9]+,)+[a-za-z0-9]+$"

works "1a,1b,1c", doesn't work on "1a"

sorry, don't know regex , got through searching.

here few example of can valid or invalid

1 - valid

12 - valid

1a - valid

a1 - invalid

12a - valid

a12 - invalid

1aa - invalid

a - invalid

1,2,3,6a,6b,11,11a - valid

invalid if other characters appear in string except numbers , letters no commas or in prefix , suffix

^\d{1,2}[a-z]?(?:,\d{1,2}[a-z]?)*$ 

try this.see demo.

https://regex101.com/r/hi0qp0/25


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -