$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;