in reply to Reg. Expression - Replace " from string

I second the recommendation to check the documentation. Still to get you started, here are a few things which solve your exact questions.
# Remove first & $str =~ s/^&//; # Remove last & $str =~ s/&$//; # Remove all & $str =~ s/&//g;
-a

Replies are listed 'Best First'.
Re^2: Reg. Expression - Replace " from string
by GrandFather (Saint) on Jun 15, 2006 at 23:37 UTC

    and to do both requested operations at once:

    $str =~ s/^&|&$//g;

    but that has just given him the fish and if this is homework then he gets the kudos (possibly) without learning anything.


    DWIM is Perl's answer to Gödel