Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: extract only uppercases from string

by grondilu (Friar)
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;'

Replies are listed 'Best First'.
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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://989272]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2018-02-19 18:46 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (266 votes). Check out past polls.