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」という文字があるのでエラーになります。誰でもこれで私を助けることができますか?前もって感謝します。
SLaks が提案するような正規表現を使用できます。
次に例を示します。
//Replaces all non-numerical characters except periods with "". String str = "Php1,500.00"; str = str.replaceAll("[^\\d.]", "");
注: 上記の正規表現はマイナス記号を削除します。
楽しむ。