Frage

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.

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top