Check if String is Integer Using Regular Expression
In .NET 2.0 there is a TryParse method for Int32. However TryParse is not compatible with .NET 1.1. The solution below is compatible with .NET 1.1 and demonstrates how to check if string is integer, using one simple regular expression.
public bool IsNumeric(string inputData) { Regex isNumber = new Regex(@"^\d+$"); Match m = isNumber.Match(inputData); return m.Success; }
Thursday, May 19, 2005 4:04 AM