in reply to Double RegEx

If you know the order in which they'll appear in the string being matched,

if($element[4] =~ /\Q$Homosapiens\E.*\Q$choromosome\E/)

will work fine. If you don't know the order, you want

if ($element[4] =~ /^ (?=.*?\Q$Homosapiens\E) (?=.*?\Q$choromosome\E) /x)

It reads: "Match homo sapiens somewhere after the start of the line, then match chromosome somewhere after the start of the line."

Update: I overlooked the obvious:

if ($element[4] =~ /\Q$Homosapiens\E/ && $element[4] =~ /\Q$choromosome\E/)

And since you're searching for constant strings, the following would be even faster:

if (index($element[4], $Homosapiens) >= 0 && index($element[4], $choromosome) >= 0)

Replies are listed 'Best First'.
Re: Double RegEx
by MonkPaul (Friar) on Jun 27, 2005 at 14:44 UTC
    Excellent
    Thas what i needed.
    I was not sure if people would get what i needed. I will just run this in my looping system and see if blast-off occurs.
    Will keep you posted.

    cheers.

Re: Double RegEx
by MonkPaul (Friar) on Jun 29, 2005 at 13:27 UTC
    One other problem i have just found - At the moment its finding "chromosome 2*" where the * represents any other number. How can i complete this so it only looks for chromosome 2 only and say not 20.

    MonkPaul.

      /chromosome 2(?!\d)/
      "chromosome 2", not followed by a digit.