Created
January 26, 2023 18:07
-
-
Save jacobmhulse/4c99928ccd7546d1c2ae75a5e90aa270 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class StringExtensions | |
{ | |
public static bool IsDate(this string value) | |
{ | |
if (DateTime.TryParse(value, out DateTime Temp) == true) | |
return true; | |
else | |
return false; | |
} | |
/// <summary> | |
/// Returns true if input contains all numbers or any currency format | |
/// </summary> | |
/// <param name="value"></param> | |
/// <returns></returns> | |
public static bool IsNumeric(this string value) | |
{ | |
string pattern = @"^\S{0,3}(kr\.)?\s*(((\d{1,3})([,\.]\d{3})*)|(\d+))(.\d+)?\s*\$?((Kč)|(Ft)|(.د.م.)|(zł)|(p.)|(﷼)|(฿)|(₺)|(₫))?$"; | |
RegexOptions options = RegexOptions.Multiline; | |
return Regex.IsMatch(value, pattern, options); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment