in reply to Search for Second Occurence of Substing and get containing text
# 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;
|
|---|