user405398
user405398

Reputation:

Regex to match comma separated values?

I am looking for a regular expression which accepts comma separated values(no space) of both string and numbers(especially mobile numbers, 10 digits) for client side validation.

I have gone through regexlib.com but i couldn't find good one.

UPDATE

Input patterns:

9655770780,college,8095145098,schoolmates

Its a just a input field, users can enter group name of mobile numbers or just the numbers.

Any suggestions!

Upvotes: 0

Views: 4905

Answers (2)

KishoreK
KishoreK

Reputation: 962

Try this pattern. This will verify if a text is a comma separated

([a-zA-Z0-9]+,)+

Upvotes: -1

Dancrumb
Dancrumb

Reputation: 27579

Regular expressions may be overkill for this problem.

You could use:

var csv_values = csv_string.split(",");

This would split on the commas and give you your values

Upvotes: 4

Related Questions