简体   繁体   中英

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.

The way I had planned it was '/==(\\r|\\n|.)*\\{\\{Description/i'

But this causes a SEGFAULT when running the regex.

How else can I build a regex to match the above without having (\\r|\\n|.)* ?

Just .* will work if you add the s modifier. 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/is

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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