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.
文字と数字だけを残すようにしています
String str = "it's too hard & jean say"; String strNew = str.replaceAll("[^A-Za-z0-9\\s]", "");
このコードで試しましたが、スペースが削除されません。
だから私はそれを削除する方法を検索します。
A-Za-z文字 ( )、数字 ( 0-9)、およびスペース( \\s) を除くすべてを空の文字列に置き換えるように指定しているため、スペースは削除されません。
A-Za-z
0-9
\\s
を削除するだけで、\\sスペースも空の文字列に置き換えられます。
String strNew = str.replaceAll("[^A-Za-z0-9]", "");