if $line =~ /^myword.*$/ { $line =~ s/$&//g } #### if $line =~ /(^myword.*option\d+\s+).*$/ { $line =~ s/$1//g }