Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
a が前に付いていないすべての改行を一致さYせ、空の文字列に置き換えようとしていますが、この式でエラーが発生します。
Y
$tsv = preg_replace("/(?<!Y)\n/m", "", $tsv);
しかし、それは何らかの理由ですべての改行を置き換えています。振り返りの何が問題になっていますか?
予想とは異なる行末を持つファイルを扱っている可能性があります。
\r
\n
\r\n
これを試して、任意の行末を処理できます。
$tsv = preg_replace("/(?<!Y)(\r\n?|\n)/m", "", $tsv);