m/ ^[$valid_chars] #the string must start with one of the valid chars (?: #start group, but don't capture! , #could have a comma [$valid_chars] #and another valid char )* #and that comma+valid char could repeat 0 or more times $ #until the end of the string /x #this is here to allow me to use all these comments