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.]", "");
注意:上面的正则表达式删除了负号。
玩得开心。