Jump to content

Determine if a string is numeric: Difference between revisions

m (Changed over to works with template, alphabetized)
Line 286:
}
 
Alternative 2 : use a regular expression (a more elegant solution). Also, only for integers.
 
public static boolean IsNumericisNumeric(stringString inputData) {
final staticreturn Regex isNumber = new RegexinputData.matches(@"^-{0,1}?\\d+(.\\d+$)?");
Match m = isNumber.Match(inputData);
return m.Success;
}
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.