Search This Blog

Sunday, December 13, 2015

How to check whether the value is numeric or Non-numeric

Example 1:
String value = 'abc';
boolean isNonNumericValue = pattern.matches('[a-zA-Z]+',value);
if(isNonNumericValue == true) {
system.debug('Non Numeric');
} else {
system.debug('Numeric');
}
Output:
Example 2:
String value = '123';
boolean isNonNumericValue = pattern.matches('[a-zA-Z]+',value);
if(isNonNumericValue == true) {
system.debug('Non Numeric');
} else {
system.debug('Numeric');
}
Output:

No comments:

Post a Comment