Hanson wrote:
>
> Hi!
>
> I need to remove the first n underscores from various
> strings if there are more than two currently present in the
> string. The total number of underscores will vary. For
> example, if I have the following strings:
>
> $a = "Now_is_the_time_for_all"
> $b = "The_quick
There are a number of different solutions for this...I'm not sure which is
the most efficient.
1.)
$var = reverse( <> );
if( $var =~ /^[^_]*?_[^_]*?_)(.*)$/ ) {
($temp = $2) =~ tr/_//d;
$var = reverse( $1 . $temp);
}
print $var;
2.)
$var = <>;
$var =~ s/_// while $var =~ /_.*?_.*?_/g;