in reply to regex: only want [a-zA-Z] and comma chars in a string
unless ( $tax_collection =~ /^[a-zA-Z]+(?:,[a-zA-Z]+)*?$/ ) { print "<font color=\"#ff0000\"><i>Incorrect format</i></font>"; $errors++; }
What that does is it says match [a-zA-Z] as many times as possible (the first word) followed by a sequence that can be repeated as many times as necessary (or no times). That sequence may start with a comma, and finish with as many [a-zA-Z] characters as possible. The match is anchored from the front of the string to the end (assuming a single-line string).
Dave
|
|---|