Monday 1 October 2012

how know String contain only numeric value


A small observation from my side that how know string contain only numeric value.
After some a small fight i got the solution it's very simple. There is many ways to find the solution like use
isNumeric() method etc
The solution which was I got that is Regex yes by Regex  we can know easily  


String x = '123 ';
Pattern numberFormat = Pattern.Compile('[0-9]*');  
Matcher numberMatch = numberFormat.matcher(x);
System.debug('::::::::::::::::::::::::::::::::'+numberMatch.Matches());

It is very simple.

Thanks,

Regards,
Ashlekh Gera.