-
-
Notifications
You must be signed in to change notification settings - Fork 10
Simplify.String
Alexanderius edited this page Jun 27, 2026
·
1 revision
Provides string operations and validation helper functions.
Available at NuGet as binary package or source package
All methods are exposed as static members of the StringHelper class.
// Parses and converts a mobile phone number to a format like +77015543456 (strips everything except digits and +).
public static string ParseMobilePhone(string phone);
// Checks if an e-mail address is correct (validated via System.Net.Mail.MailAddress).
public static bool ValidateEMail(string eMail);
// Checks if a mobile phone number is correct (must match ^\+[1-9]{1}[0-9]{4,12}$).
public static bool ValidateMobilePhone(string phone);
// Indistinct (fuzzy) matching of two strings. Returns the similarity percentage (0..100)
// by comparing blocks of increasing length up to comparingBlockLength.
public static float IndistinctMatching(string stringA, string stringB, int comparingBlockLength = 3);
// Strips HTML tags from the source string.
public static string StripHtmlTags(string source);Note:
StripHtmlTagsis a cosmetic tag remover (a simple<.*?>regex), not an HTML/XSS sanitizer. Do not rely on it to make untrusted input safe for rendering — it does not handle malformed tags, comments, scripts, or attributes.
var normalized = StringHelper.ParseMobilePhone("+7 (701) 554-34-56"); // "+77015543456"
if (!StringHelper.ValidateEMail(email))
throw new ArgumentException("Invalid e-mail address");
var similarity = StringHelper.IndistinctMatching("Microsoft", "Mircosoft"); // high percentage