in reply to Regular Expression Question
It's probably simpler and clearer (as well as more efficient) to use two regexes for this type of thing.
for ('fred,bill', 'fred,,bill', ',fred', 'bill,') { print "Bad:'$_'" unless $_ =~ m[^[a-zA-Z0-9,]+$] and $_ !~ m[,{2}|,$|^,]; } Bad:'fred,,bill' Bad:',fred' Bad:'bill,'
|
|---|