http://www.perlmonks.org?node_id=298710


in reply to regex: only want [a-zA-Z] and comma chars in a string

If you're new to regexes, it might be helpful (although it will slow down processing slightly) to break this down into each thing you are trying to test. That may help you later when coming back to the code to figure out what you were testing for.

For example:

print "$_\n" if !/^,/ && !/,$/ && !/,,/ && /^[a-zA-Z,]$/;