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 關注
- 108 瀏覽
添加回答
舉報