$x =~ m!\d+\s*\w+!; # Note that the "m" prefix is required except when the delimiter is "/" $x =~ s!\d+\s*\w+!_!;