Hi all, I want a regex to replace all continuous occurrences of '-' with something else say 'x' except the first one
These are some examples "- Ram" ===> "- Ram" "-- bla" ===> "-x blah" "bla ---" ===> "bla -xxx" And also "-- blah ---" ===> "-x blah -xx" What I am doing now is a workaround works fine but I think it is an overkill -------------------------- # The input string $x="- -- blah --- blah2"; my $RANDOM='@@@'; # Replace the begining '-'s with @@@ $x=~s/(?<!-)-(?=-*)/$RANDOM/g; # Replace other '-'s with x $x=~ s/-/x/g; # Restore the begining '-'s $x=~s/$RANDOM/-/g; print "$x\n"; ----------------------------------------- Thanks Ram ---------------------------------------------------------- Netcore Solutions Pvt. Ltd. Website: http://www.netcore.co.in Spamtraps: http://cleanmail.netcore.co.in/directory.html ---------------------------------------------------------- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>