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.
|
|---|