in reply to Extracting Text Using Regular Expressions Problem

As a meta-answer to you question, if you keep posting questions and don't get working answers, it's quite possible you are asking the wrong questions. A read through I know what I mean. Why don't you?, XY Problem and On Asking Questions of Bears might do you well. As well, if code provided doesn't work, make sure you are giving us good examples of input and output. It's also possible that regular expressions are not the right tool for the task you are trying to accomplish.

As well, as you've posted on this issue before, it's generally considered good form to keep it in a thread or at least cite your previous postings on the issue (I'm guessing Search for Second Occurence of Substing and get containing text and Searching string for paragraph..).

For your actual question, your specification leaves something to be desired. I will read it as "Extract all text following '===Comments===' until the next '=' or end of file and then extract all text following '=Aditional Notes=' until the next '=' or end of file". Note the misspelling of Aditional<sic>. The following will take your posted material and capture the strings in question into arrays. If this does not work for your actual text, post that case so we can have accurate input for test cases.

#!/usr/bin/perl use strict; use warnings; my $text = do { local $/; #slurp <DATA>; }; my @comments = $text =~ /(?<====Comments===).*?(?==|$)/gs; my @additional = $text =~ /(?<==Aditional Notes=).*?(?==|$)/gs; 1; __DATA__ ===Comments=== This webpage contains information bla bla bla =Section 2= Some more text here. ===Comments=== Some other comments here. =Another section= =Aditional Notes= More notes here.