This will match zero or more numbers followed by optionally a comma and one or more numbers. e.g: 1,2345; 123; 12,34; ,25 (leading zero may be omitted)
You can then replace the comma with a dot (string.replace(',', '.')) and do what you want with it :)
This will match zero or more numbers followed by optionally a comma and one or more numbers. e.g:
1,2345; 123; 12,34; ,25 (leading zero may be omitted)
You can then replace the comma with a dot (
string.replace(',', '.')
) and do what you want with it :)You can use String.split() with
space
as a delimilter and than use String.replaceAll() to replace,
with.
.After that use parseDouble.It returns,
Output =
123.45
Search for
Balance (\d*),(\d*) p\.
Replace withdouble \$1.\$2
This works in IntelliJ IDEA
Note: Not a Regex based solution.
To me it seems that the String that you are getting is from a locale where decimal separator is
,
instead of.
, you can just do something like this: