Wednesday, September 11, 2013

How to write regex to verify a comma delimited list of values

How to write regex to verify a comma delimited list of values

I am using SobiPro, a directory system for joomla and I have a field that
will have values that contain alphanumerics and hyphens only, so a sample
of what might be in this text field would be:
Toy Kites, Plastic Wheels, 1-Way Gizmos, Metal Spools, 3M Wire Ties
This regex would validate what they enter on the form prior to a field save.
I thought this: (\w+)(,\s*\w+)*
But clearly I am not right, and it does not account for the hyphens.. any
help! thanks!

No comments:

Post a Comment