I need regex that will match this
Fred, Jhon, Tree,
and there could be some spaces between the commas and the words, and between the start of the line and the first word. Can anyone help me with this ?
I need regex that will match this
Fred, Jhon, Tree,
and there could be some spaces between the commas and the words, and between the start of the line and the first word. Can anyone help me with this ?
(\w\s*,){3} will matach a word, some or no spaces, and a comma exactly 3 times
/^ *Fred *, *Jhon *, *Tree *,$/
Simple explanation: / */ is a regex that matches space zero or more times. Fred matches Fred, John John, etc pp use / +/ instead if you wish at least one space
^ matches the start and $ the end.
note: using /\s*/ fragments instead of / */ fragments matches all whitespace - including tabs, newlines, etc