I wrote the following program to remove leading and trailing zeroes from a
string using regex.
Without the 8th line, the output is
And with it the output is.
I do not understant why the string becomes null in the second case even when m.matches() returns true. I think that the
pattern says, "match zero or more occurances of a character that is not zero, then match one or more occurances of any digit and again match zero or more occurances of a character that is not zero". If I am wrong then please tell me the right way to do it.