String cleansing

  • Thread starter Thread starter Patrick de Ridder
  • Start date Start date
P

Patrick de Ridder

Given a short string that should only contain an (integer) number, is there
a way to filter out anything that is not a number?
Many thanks.
Patrick.
 
use the following method

private static Regex _isNumber = new Regex(@"^\d+$")

public static bool IsInteger(string theValue

Match m = _isNumber.Match(theValue)
return m.Success
} //IsInteg

Regards
AMAL
 
Patrick de Ridder said:
Given a short string that should only contain an (integer) number, is there
a way to filter out anything that is not a number?
Many thanks.
Patrick.

Hi,
A Tip. Try using regular expressions.
 
Back
Top