EREG expression for one or more first names separated by comma
I somehow can't get this to work. I want at least one name but also the possibility to add more names separated by a comma and space.
This is what i got:
var exp_name2 = /^[A-Z]{1}[a-z-]*[,\s][A-Z]{1}[a-z-]$/;
Any ideas how I can 开发者_如何转开发do this?
Alright, so you're wanting it to be like this: Name, nAme lastname,NAME
[a-zA-Z\s]*(?:,?[\s]?)?
Selects either lowercase or uppercase letters until it hits a ,
or a space, then repeats.
Otherwise: Name, Name, Name
[A-Z][a-z\s]*(?:,\s)?
This is something that should work. Check it out http://jsfiddle.net/bZy5Q/1/
精彩评论