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.
数字、文字、_(アンダースコア)、:(コロン)を除くすべてを文字列から削除したい
これはPREGで、#\ W#にしか出くわしませんが、:(コロン)が削除されます。
どんな助けでもありがたいです、ありがとう!
[^\w:]+[^...]-文字、数字、アンダースコア(\w)、またはコロン( )以外のものはすべて削除し:ます。
[^\w:]+
[^...]
\w
:
サンプルコード:
$ptn = "/[^\w:]+/"; $str = "Hello~~~ World+++: 123"; echo preg_replace($ptn, "", $str);
出力:HelloWorld:123
HelloWorld:123