Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: extract only uppercases from string

by grondilu (Pilgrim)
on Aug 23, 2012 at 10:41 UTC ( #989272=note: print w/ replies, xml ) Need Help??


in reply to extract only uppercases from string

I'm not sure it's easy to do it in just one regex.

But you can just use two steps:

my $seq = "G_I1E2_GTGGAG^303CTGgacgCCCTGC_I2E3_TACA"; $seq =~ s/[^ACTGactg]//g; my @result = $seq =~ /[ACTG]+/g; say for @result;

You can do it in one line if your version of perl is recent enough to support the r regex modifier:

perl -wE 'say for "G_I1E2_GTGGAG^303CTGgacgCCCTGC_I2E3_TACA" =~ s/[^AC +TGactg]//gr =~ /[ACTG]+/g;'


Comment on Re: extract only uppercases from string
Select or Download Code
Re^2: extract only uppercases from string
by losher (Initiate) on Aug 23, 2012 at 10:53 UTC
    Little modification of your idea works for me!
    Thanks a lot!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://989272]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (10)
As of 2014-07-14 09:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (257 votes), past polls