in reply to a small regexp question

This appeared to break the exact stipulations of the OP, but on the other hand... at least the input and output rules are obeyed by this:
$string="a_sample_string"; #... my $disposable = $string; # put it in a disposable variable $disposable =~ s/_/ /g; # substitution on that instead $disposable =~ /^(.*)$/; # then put it in $1

One world, one people