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.
PHP で LaTeX パーサーを作成しようとしていますが、特定の末尾の改行 (\\記号) を削除したいと考えています。
\\
しかし、問題は、それが他のすべての前にある場合にのみ、新しい行 (二重のバックスラッシュ) を削除したいということです。
同様に\\、次の例の最初の部分を削除します。
\\3+6=9
しかし、これではありません\\:
3+\\6=9
PHPでこれを行うにはどうすればよいですか?
使用するtrim
trim
$arr = trim('your_string','\\');
実際の例http://codepad.viper-7.com/OaYxWG
あなたは次のことができます
$a = "\\aaaaa"; if (substr($a, 0, 1) === '\\') { echo trim($a,'\\'); }
「aaaaa」がエコーアウトします。お役に立てれば
PHPでトリムを使用する
i.e., trim("string","\\");