Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
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 exploiting the Monastery: (5)
As of 2015-07-06 00:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (68 votes), past polls