Friday, October 8, 2010

Regex for valid currency

///
/// Determines whether [is valid currency] [the specified temp].
///

/// The temp.
///
/// true if [is valid currency] [the specified temp]; otherwise, false.
///

public static bool IsValidCurrency(string temp)
{
bool isValidCurrency = true;
Regex regularExp = new Regex(@"^([0-9]{1,16}(.[0-9][0-9]))?$");
if (!regularExp.IsMatch(temp))
{
isValidCurrency = false;
}
return isValidCurrency;
}

No comments:

Post a Comment