我有 100 多个文本文件,其中包含以下格式的文本。
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
我需要捕获/获取“必需信息”和“信息..”之间的所有文本,跨越多行。
我正在将所有文件读入 $str。我提出的正则表达式是
$pattern = "/Required Info(.+?)info\.\./im";
preg_match($pattern, $str, $matches);
print_r($matches);
现在,这是在http://rubular.com/r/sP26IahrgI工作,但不是在我自己的本地 XAMPP。$matches 只是显示为空。
我对 RegEx 很陌生,并试图一起学习。我的正则表达式错误吗?