I want to match:
- aaa
- aaa,bbb
- aaa,bbb,ccc
But not a list with a trailing comma. My current regex:
(\w{3},?)+
also matches lists with trailing commas (aaa,bbb,
). I was thinking I could also do:
(\w{3})(,\w{3})*
but that is rather ugly. My real regex is not matching 3-letter-words, but something bigger, and repeating the regex is ugly. How can this be fixed?