문제

Textbox Example

Is there a way that I can get the numerical value from the textbox? The value in the textbox is in currency form. I want to multiply the value from this but I get an error because there is letters "Php". Can anyone help me with this? Thank you in advance.

도움이 되었습니까?

해결책

You can use a regular expression like SLaks suggested.

Here is an example:

//Replaces all non-numerical characters except periods with "".
String str = "Php1,500.00";
str = str.replaceAll("[^\\d.]", "");

Note: The regular expression above removes negative signs.

Have fun.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top