1 回答
TA贡献1856条经验 获得超17个赞
$searchstring = "We got an example here which covers it to 99% all and this sentence is already part of it. Because this is the first Markerword: with a lot of other things like commata, special characters ä, ü, ß or % and more in it. This proper Markerword: contains more of it multiple times and in caotic characters. If the Markerword: contains this, then cut the whole sequence out - until the first dot after that markerword. And if there are other sentences or even just words inbetween or at the end or before we ignore them all.";
preg_match_all('/\bMarkerword:[^.]+\./', $searchstring, $m);
$result = implode(' ', $m[0]);
echo $result;
输出:
Markerword: with a lot of other things like commata, special characters ä, ü, ß or % and more in it. Markerword: contains more of it multiple times and in caotic characters. Markerword: contains this, then cut the whole sequence out - until the first dot after that markerword.
正则表达式解释
- 1 回答
- 0 关注
- 83 浏览
添加回答
举报