using System.Text.RegularExpressions;
public static void Main()
Program p = new Program();
Console.WriteLine(p.ValidateString(",;helloworld", 5, 30));
public string ValidateString(string stringValue, int minLength, int maxLength)
if (string.IsNullOrEmpty(stringValue))
Regex rgx = new Regex($"^[,;a-zA-Z0-9._-]{{{minLength},{maxLength}}}$");
if (rgx.IsMatch(stringValue))