预匹配所有文本不匹配超过初始行

Preg Match All Text not matching past the initial line

所以我正在开发一个 PHP 应用程序,用户可以在其中使用关键字存储文本,即关键字 "Br" 文本 "Back bone polished"。对于这个特定的部分,用户将能够编辑他们存储在数据库中的所有文本。信息将在标准文本区域内显示如下:

文本区

<textarea rows="15" cols="20" id="inputMulti" wrap="hard" name="inputMulti">

文本区域内的实际文本

na  "No acute cardiopulmonary abnormality. "

!   "Test Bed - Chrome on MacBook Pro.

1. Font is not Courier.
2. Compiler is not working.
3. Buttons are not high-lighting.
4. Edit and Delete buttons not working in Reports.
5. multiple codes "entered" are inappropriately separated by commas, that are carried over from box 1. 
6. On Show list page, instead of view, we can just simplify and go straight to edit.
7. Once you Delete a code from the Code View page, you get an Page Not Found error.
8. MRI Code Typer is not linked to Home; and actually, Home doesn't need to be there, the MRI Code Typer 2 would be fine.
9. Box 2 doesn't lengthen as expected; once text field is expanded, "only" a part of it is seen, until additional typing is performed, only then does Box 2 expand properly."

0c  "Comparison: unavailable . 

FINDINGS:

$$$L,PL,H,B,f0$

IMPRESSION:
$na$
$$"

L   """""There is no discernible mass or lobar pneumonia. "

f0  "No displaced fracture or acute osseous deformity is seen. "

密钥在 \t" 之前,相应密钥的文本在相应的 "" 内。

现在我要做的是将所有内容拉到相应的“”之间。 delima 是我不能通过 " 展开,因为 "" 中的文本可能包含 ",这当然会导致问题。

我已经成功创建了一个 preg_match_all 表达式,如下所示。

preg_match_all("/[\t][\"^\a](...*)[\"$\z\n\r]/", $input_lines, $output_array);

来自 Preg Match All 的输出

array(
0=> "No acute cardiopulmonary abnormality. "
1=> "Test Bed - Chrome on MacBook Pro.
2=> "Comparison: unavailable . 
3=> """""There is no discernible mass or lobar pneumonia. "
4=> "No displaced fracture or acute osseous deformity is seen. "
)

现在这部分工作了,因为它为每一行抓取了正确的文本,但是如果你注意到键 2 它不包括“”之间的所有文本,因为它在初始匹配后停止,尽管它应该继续直到它到达扩展到多行的比赛结束。

我曾尝试添加 s 修饰符,但这只会将所有匹配项放入一个未按行拆分的数组中。我还尝试了 m 修饰符,它似乎根本没有改变任何东西。

经过几次测试,我想我明白了。试试这个模式:

preg_match_all("/\t\"([^\t]*)\"/", $input_lines, $output_array);

该模式匹配除制表符(关键字和文本之间的分隔符)以外的所有内容。在多行文本的情况下,这将包括匹配中的换行符。为此,我正在考虑文本中间不会有制表符,即制表符仅用于将关键字与其对应的文本分开。