Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: extract only uppercases from string

by fisher (Priest)
on Aug 23, 2012 at 10:18 UTC ( #989261=note: print w/ replies, xml ) Need Help??


in reply to extract only uppercases from string

Well, what did you try?


Comment on Re: extract only uppercases from string
Replies are listed 'Best First'.
Re^2: extract only uppercases from string
by losher (Initiate) on Aug 23, 2012 at 10:39 UTC
    ie. for the left string I have tried trick like:
    if ($string =~ m/([ACTG]+).*[actg]/) {
    print $1
    }
    and several other variations but all I get is an uppercase string till the first character other than ACTG.
      #!/usr/bin/perl -- use strict; use warnings; use Data::Dump; $_ = 'G_I1E2_GTGGAG^303CTGgacgCCCTGC_I2E3_TACA'; my @matches = ""; while( m{ ([ACTG]+)# $1 is upper | ([actg]+) # $2 is lower }gxsm ){ if( $1 ){ $matches[-1] .= $1; } if( $2 ){ push @matches, ""; } } dd \@matches; __END__ ["GGTGGAGCTG", "CCCTGCTACA"]

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2015-07-31 05:58 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 (274 votes), past polls