[nextpage]
bbcodeの後の任意の文字に一致させたいが、以下のbbcodeは改行するときに続くテキストと一致しない。Regexで改行するすべての文字を一致させる
$string="[nextpage] This is how i decided to make a living with my laptop.
This doesn't prevent me from doing some chores,
I get many people who visits me on a daily basis.
[nextpage] This is the second method which i think should be considered before taking any steps.
That way does not stop your from excelling. I rest my case.";
$pattern="/\[nextpage\]([^\r\n]*)(\n|\r\n?|$)/is";
preg_match_all($pattern,$string,$matches);
$totalpages=count($matches[0]);
$string = preg_replace_callback("$pattern", function ($submatch) use($totalpages) {
$textonthispage=$submatch[1];
return "<li> $textonthispage";
}, $string);
echo $string;
これは、最初の行のテキストのみを返します。
<li> This is how i decided to make a living with my laptop.
<li> This is the second method which i think should be considered before taking any steps.
予想される結果です。
<li> This is how i decided to make a living with my laptop.
This doesn't prevent me from doing some chores,
I get many people who visits me on a daily basis.
<li> This is the second method which i think should be considered before taking any steps.
That way does not stop your from excelling. I rest my case.