Alex Rivera | Logout

Regular expression for a list of items separated by comma or by comma and a space

Asked 2011-02-15T09:00:43.360
33

Hey, I can't figure out how to write a regular expression for my website, I would like to let the user input a list of items (tags) separated by comma or by comma and a space, for example "apple, pie,applepie". Would it be possible to have such regexp? Thanks!

EDIT: I would like a regexp for javascript in order to check the input before the user submits a form.

Edit
Report

1 Answer

2

This might work:

([^,]*)(, ?([^,]*))*
answered 2011-02-15T09:05:38.473

Your Answer