hailholyghost has asked for the wisdom of the Perl Monks concerning the following question:
Hello perlmonks,
I am attempting pattern match on lines like this:
"Klhl21 NM_001033352 chr4 + 152008890 152017677 152008942 152015628 4 152008890,152012299,152014306,152015334, 152009963,152012705,152014379,152017677,"
I don't know how to write regex with "=~ m/" with an unknown number of commas to get the second two integer groups into memory. There can be a lot of these integers and writing a regex manually is impractical. There must be a smarter way to match the last two integer groups. So far, what I have is:
if (/^(.*)\s+(.*)\s+chr(.*)\s+([+-])\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s ++(\d+)/) {#indexed by RefSeqID
this reads all data but the last two integer groups into %D.
How can I pattern match the last two integer groups, with unknown numbers of alternating "(\d+),(\d+),(\d+)"?
Thanks,
-DEC
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Alternating Integers and Commas in Regex
by hdb (Monsignor) on Jan 20, 2015 at 14:24 UTC | |
by hailholyghost (Novice) on Jan 20, 2015 at 15:04 UTC | |
|
Re: Alternating Integers and Commas in Regex
by johngg (Canon) on Jan 20, 2015 at 14:41 UTC | |
|
Re: Alternating Integers and Commas in Regex
by davido (Cardinal) on Jan 20, 2015 at 17:06 UTC | |
|
Re: Alternating Integers and Commas in Regex
by locked_user sundialsvc4 (Abbot) on Jan 20, 2015 at 18:17 UTC |