$line =~ s/^myword \S+//; # strip myword, a space, and any stretch of non-spaces #### $line =~ s/^ #strip, from the beginning of the string, myword\s+ #myword, followed by whitespace \S+ #followed by non-whitespace (?:,\s*\S+)* #followed by any number of comma, optional whitespace, non-whitespace //x; # update: two slashes are needed here