as part of the small program that I am writing, I need to filter out the String input, which can be "gibrish" (any character in UTF8), the input can be Hebrew and / or English, but also have all the usual characters, such as:?% $! @'_' etc.
A friend suggested using a regular expression, but because of my inexperience with using it, I come to you for advice.
how can I create a C # function to check the input text and if it is not "correctly" returns false
My attempt:
public static bool shortTest(string input) { string pattern = @"^[אבגדהוזחטיכלמנסעפצקרשתץףןםa-zA-Z0-9\_]+$"; Regex regex = new Regex(pattern); return regex.IsMatch(input); }
all characters after "[" and "a" are Hebrew
source share