I am a newbie in java regex. I would like to know how to extract numbers or float numbers before %. For example:
"Titi 10% Toto and tutu equals 20X"
"Titi 10.50% Toto and tutu equals 20X"
"Titi 10-10.50% Toto and tutu equals 20X
"Titi 10sd50 % Toto and tutu equals 20X
"Titi 10-10.50% or 10sd50 % Toto and tutu equals 20X
Output :
10
10.50
10-10.50
10sd50
10-10.50;10sd50
My idea is to replace all before and after "space + number(% or space%)" by ; in order to extract all values or group values before %. I tried to use that: replaceAll("[^0-9.]+|\\.(?!\\d)(?!\\b)\\%",";"); = NO SUCCESS
How can I do it?
10sd50is not a number, nor10-10.50+/-withsd? Was this done by your program, intentionally or unintentionally?