in reply to Search for Second Occurence of Substing and get containing text

The previous replies probably give enough to go on, but the OP question wasn't clear. To expand a bit, one of the following two methods would be useful, depending on what the question really meant:
# scenario 1: $data = <<EOT1; ignore this part ===Comments=== ignore this part too ===Comments=== capture this part =Microarray Data= EOT1 $match = ( $data =~ /.*===Comments===(.*?)=Microarray Data=/s )[0]; print $match; # scenario 2: $data = <<EOT2; ignore this part ===Comments=== ignore this also =Microarray Data= and ignore this ===Comments=== this is what we want =Microarray Data= EOT2 $match = ( $data =~ /===Comments===(.*?)=Microarray Data=/sg )[1]; print $match;
The basic point is that a regex match will return its capture(s) as a list, which you can then pick from via an array slice (or assign to an array or list).
  • Comment on Re: Search for Second Occurence of Substing and get containing text
  • Download Code