I need to parse this String "/<productId>/save"
and I have to ensure that productId is an unsigned integer of 32 bits.
Of course I could split the String using the character "/" and then in the returned array try to cast the product Id to an Integer and see if I get an exception or not, but it does not seem a very elegant solution.
Instead I've tried using this regular expression boolean match=path.matches("\\/\\d+\\/save");
which works fine but it is not respecting the restriction of the integer of 32 bits, basically I can enter a number of any size.
I.e the followinf string /44444444444444444/save";
matches the regular expression.
What is the more elegant way to do this? Could you recommend me any approach?