develooper Front page | perl.beginners | Postings from February 2009

Re: RegExp Problem using Substitutions.

Thread Previous | Thread Next
From:
Rob Dixon
Date:
February 24, 2009 04:18
Subject:
Re: RegExp Problem using Substitutions.
Message ID:
49A3E5A9.3060908@gmx.com
Deviloper wrote:
> Hi there!
> 
> I have a string "aaaabbbababbaaassass". I want to get a string without any double a 'aa' or and without the 'b's.
> 
> but if I do:
> 
> my $s = "aaaabbbababbaaassass";
> $s=~ s/aa|b//g;
> 
> as a result I will get a string "aaassass".
> 
> (I understand WHY I get this result. 
> But I don“t know how to avoid this. (Using only one substition.))

Why do you insist on using a single substitution? Unless you are entering a
competition you should be looking for functionality and clarity - not adherence
to some arbitrary challenge.

Rob

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About