Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: regexp and substitute operator problem

by BrowserUk (Patriarch)
on Jul 08, 2003 at 06:51 UTC ( [id://272214]=note: print w/replies, xml ) Need Help??


in reply to regexp and substitute operator problem

When I run your code, I get a quite different set of results from those you posted.

P:\test>test Xq27-q28 22q12.1 19q 1q25 11p11.2 10q23.31 8p22 7p22 19q12-q13.11 52 15 19q12-

Which makes it difficult to try and answer your two questions.

In any case, it is probably better to specify the regex more accurately so that you don't capture the unwanted values in the first place. This seems to do the trick on the sample you supplied.

#! perl -w use strict; my $text = <DATA>; my $re_1chrom = '[\dXY]*[pq]\d+(?:.\d+)?'; my $re = qr[\b$re_1chrom(?:-$re_1chrom)?\b]i; my @chroms = ( $text =~ /$re/g ); print $_, $/ for @chroms __END__ P:\test>test Xq27-q28 Xq11-q12 22q12.1 1q42.2-q43 17p11 1q25 13q12.3 11p11.2 10q25 10q23.31 8p22 8p22 7q11.23 7p22 19q12-q13.11 19q12-q13.11

The sequential double reference to 8p22 seems odd in context, but eliminating that and the other duplicate(s) is a simple step.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller


Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-03-28 18:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found