Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top