In PHP I’m looking to match everything until a certain word appears:
$text = "String1
.
testtesthephepString2 Here";
$faultyregexp = "#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 thesmodifier (PCRE_DOTALL):