Std_English,A2,B3|Std_Arts,A2,B6|Std_Cultural,A1,E8 #### $input =~ /^ (?: # Non-capturing parens [^_] # All non-underscores | # or _ # underscore (?! # not followed by ${value} # the current standards ) )+ # 1 or more characters like above _${value}, # Current standard followed by comma ( # Capture to $1 (?: # Non-capturing parens [A-Z]\d{1,2},? # One cap, one or two digits, and an optional comma )+ # Above one or more times ) # End capture .* # Rest of line (okay to be greedy here) /ix;