私は正規表現を初めて使用します。誰かがこの行の内容を教えてくれますか?
$body = preg_replace('/\s{6,}/ms','',$body);
前もって感謝します。
私は正規表現を初めて使用します。誰かがこの行の内容を教えてくれますか?
$body = preg_replace('/\s{6,}/ms','',$body);
前もって感謝します。
$body = preg_replace('/\s{6,}/ms','',$body);
\s
6〜未定義の時間()で発生するスペース({6,}
)を何も置き換えないでください。この複数行を実行します。(/m
)。はs
削除できます。「すべての文字」の文字()を使用しない場合、値は追加されません.
。
少なくとも 6 つの連続した空白文字の発生を削除します。
\s - 空白
(水平) タブ、スペース、ライン フィード、キャリッジ リターン、またはフォーム フィードとして定義されます。
パターン修飾子は役に立たないところで:
m
^
との動作を変更します$
s
.
改行文字も一致させます。そうしないと、行末で停止します。基本的に、その言い回しは、6つのスペースを続けて置き換えます。
\s = space
{6,} = between 6 and (since the second number after the comman is blank) 6
\ms = Used together, as /ms, they let the "." match any character whatsoever, while still allowing "^" and "$" to match, respectively, just after and just before newlines within the string.
また、perlの正規表現については、perldocを確認してください。将来的に役立つ可能性があります。