简体   繁体   English

正则表达式,匹配php(\\ r | \\ n |。)中的任何内容*

[英]Regex, match anything in php (\r|\n|.)*

I have a massive string containing various segments of text. 我有一个巨大的字符串,其中包含文本的各个部分。 Part of the way through these strings there are two equals signs ' == '. 通过这些字符串的方式中,有两个等号' == '。

I want to match ' {{Description ' if it is after there equals signs. 我想匹配' {{Description '如果在等号之后。

The way I had planned it was '/==(\\r|\\n|.)*\\{\\{Description/i' 我计划的方式是'/==(\\r|\\n|.)*\\{\\{Description/i'

But this causes a SEGFAULT when running the regex. 但这在运行正则表达式时会导致SEGFAULT。

How else can I build a regex to match the above without having (\\r|\\n|.)* ? 在没有(\\r|\\n|.)*情况下,我还能如何构建一个与上述内容匹配的正则表达式?

Just .* will work if you add the s modifier. 如果添加s修饰符,则仅.*将起作用。 Also, { has a special meaning (introduces a numeric quantifier) so it should be escaped. 另外, {具有特殊含义(引入数字量),因此应将其转义。 Finally, * should probably be made lazy, otherwise it will look for the LAST appearance of {{Description 最后, *应该变得懒惰,否则它将寻找{{Description

/==.*?\{\{Description/is

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM