#!usr/bin/perl -w use strict; my @lines = qw( >sp|P49929|SC52_SHEEP DITCAEPQSVRGLRRLGRKIAHGVKKYG >gi|1771590|emb|CAA70562.1| temporin B precursor ); foreach (@lines) { if (/^>(\w+)\|([^|]+)/){ print "$1 == $2\n"; } } __END__ Prints: sp == P49929 gi == 1771590
Also, if the second field only contains word charcters you could use a simpler match: /^>(\w+)\|(\w+)/
--
John.
In reply to Re: get some part of the string using regex
by jmcnamara
in thread get some part of the string using regex
by gdnew
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |