我有形式有错误的文件:PHP正则表达式和preg_match_all()问题
================================================
Header of file with date and time
================================================
Loaded options from XML file: 'path/to/file/some_file.xml
extendedPrintPDF started
extendedPrintPDF: Error: Unsaved documents have no full name.; line: 332
================================================
Header of file with date and time
================================================
Error opening document: path/to/file/some_file1: Error: Either the file does not exist, you do not have permission, or the file may be in use by another application; line: 190
Error opening document: path/to/file/some_file2: Error: Either the file does not exist, you do not have permission, or the file may be in use by another application; line: 190
我使用
preg_match_all('/Error: (.*)/m', $file_data, $erroenames,PREG_PATTERN_ORDER);
获得阵列中的所有错误。 它似乎在第一组中的错误正常工作。但是,以'Error Opening document'开头的第二组错误似乎显示为数组的单个元素,因此,我只有4个元素而不是9个数。但是,当我在http://www.spaweditor.com/scripts/regex/index.php上尝试相同的操作时,所有的错误显示为数组的不同元素,我得到9个元素。 有人能告诉我我做错了什么吗? 我试过使用|并为“错误打开文档”创建一个RegEx。但是,即使这似乎不起作用。
如何检索'$ file_data'?我尝试了成功的正则表达式...... –
也许“错误打开文档”条目不能用换行符分隔(例如
)。 – periklis
@ Tiger-222:我正在使用file_get_contents。这是 的延续http://stackoverflow.com/questions/13995685/reading-errors-and-file-names-from-a-log-txt-file –