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.
文字列の最初の文字である場合にのみ、コロンを削除したいと思います。以下を試しましたが、うまくいきません。どんな助けでも大歓迎です:
//remove the colon if its the first character.. $pattern = '/^:/'; $replace = ''; $tweet = preg_replace($pattern, $replace, $tweet);
コロンをエスケープします。
$pattern = '/^\\:/';
コロンを単独でセットに入れることもできます。これは読みやすいかもしれません:
$pattern = '/^[:]/';