I have 100+ text files containing the text in the following format..
Some Clutter...
This text file is written by using GuavaSoft Notepad.
some more info
Required Info: some text here, some text here also, a new line
text on another new line, SOME CAPITAL TEXT, one more new line,
some numbers, some punctuation marks,
some completely empty line to follow
some empty lines with tab-spaces, spaces to follow
ok, this is the end of required info..
some more unnecarry lines
empty line
etc
etc
I need to capture/get all the text between “Required Info” and “info..”, spanned on multiple lines.
I am reading all the file into $str.
The regex I have come up is
$pattern = "/Required Info(.+?)info\.\./im";
preg_match($pattern, $str, $matches);
print_r($matches);
Now, this is working at http://rubular.com/r/sP26IahrgI But not at my own Local XAMPP. $matches is just showing empty.
I am very new to RegEx and trying to learn along. Is my Regex expression wrong?
You need to add the
sflag so(.+)will match with newlines too.