I have a question - Can i use a second regex when looking through a line in a file.
For instance i am currently looking for Homo sapien in one line of a file, but i also want to look for chromosome 11 say. At the moment, i am saving the filtered data from Homo sapiens search into an array, then conducting the search on this to find the chromosome 11.
for (my $i = 0 ; $i<scalar @line; $i++) { if ($line[$i] =~ /^>/) { $current_subject = $line[$i]; chomp ($current_subject); push (@filtered_subjects, $current_subject); } } my @element;
So stored in the array is:
>gi|14670349|ref|NM_032999.1| Homo sapiens general transcription facto +r II, i (GTF2I), transcript >gi|2827179|gb|AF035737.1|AF035737 Homo sapiens general transcription +factor 2-I (GTF2I) mRNA, complete >gi|19908489|gb|AF343351.1| Mus musculus TFII-I repeat domain-containi +ng protein 3 beta 7 mRNA,
Is this the best way to do it, or can i use something like:foreach my $z (@filtered_subjects) { chomp $z; @element = split('\|', $z); if($element[4] =~ /\Q$Homosapiens\E/) { push(@chromoLine, $z); } } }
if($element[4] =~ /\Q$Homosapiens$choromosome\E/)
Any help is appreciated.
thanks,
MonkPaul.
In reply to Double RegEx by MonkPaul
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |