In PHP I'm looking to match everything until a certain word appears:
$text = "String1
.
testtesthephepString2 Here";
$faultyregexp = "开发者_JAVA百科#String1(.+)String2 Here#";
preg_match($text, $faultyregexp, $result);
Now I want to match everything between String1 and String2, but for some reason this doesn't work.
I'm thinking you could do something like #String1(^String2 here+)String2 here# if you know what I mean :) ?
The issue is that by default . does not include newline characters. If you want . to match all character, you need to specify the s modifier (PCRE_DOTALL):
/String1(.+)String2 Here/s
加载中,请稍侯......
精彩评论