Reputation: 771
I have following strings:
S/. 05.56
S/. 0.0
S/. 0.00
S/. 90.10
S/. 01.23
S/. 1.00
S/.1.80
$/.9.80
$/. 10.80
$/. 89.81
$ 89.81
I need this output
05.56
0.0
0.00
90.10
01.23
1.00
1.80
9.80
10.80
89.81
I need to remove all non-digit character before first number, Then regex haven't to remove decimal point
I tried this regex but doesn't work:
e.replaceAll("[a-zA-z](/.)( )*", ""); //don't remove $
e.replaceAll("[^0-9.]", ""); //This show .3.4 I need remove the first point decimal
I need to remove all monetary symbol
Thanks for help!
Upvotes: 0
Views: 649
Reputation: 36304
Use ^\\D+
to replace all non-digits from the beginning of each string.
public static void main(String[] args) {
String[] str = { "S/. 05.56", "S/. 0.0", "S/. 0.00", "S/. 90.10", "S/. 01.23", "S/. 1.00", "S/.1.80",
"$/.9.80", "$/. 10.80", "$/. 89.81", "$ 89.81" };
for (String s : str) {
System.out.println(s.replaceAll("^\\D+", ""));
}
}
O/P :
05.56
0.0
0.00
90.10
01.23
1.00
1.80
9.80
10.80
89.81
89.81
Upvotes: 1