Remove trailing zeros from string java -
this question has answer here:
- regex removing trailing zeros 5 answers
although have seen question similar 1 asked quite few times, mean remove trailing zeroes.
i convert like
"1903895810000"
to
"190389581"
i looking string.replace() solution
simple regexp replaceall
it.
string s = "1903895810000"; system.out.println(s.replaceall("0+$", ""));
[edit]:
s.replace(0, "")
not work here, because remove zeros string, can't use it. so, here used replaceall
, uses regular expressions match replacement string. simple regexp 0+$
matches number of zeros 0+
followed end-of-string $
, "some zeroes @ end".
Comments
Post a Comment