If I have these strings:
\"abc\" = false
\"abc\"
false
\"123\" = true
\"123\"
true
\"ab2\"
Try the reges below
new Regex(@"^\d{4}").IsMatch("6") // false new Regex(@"^\d{4}").IsMatch("68ab") // false new Regex(@"^\d{4}").IsMatch("1111abcdefg") new Regex(@"^\d+").IsMatch("6") // true (any length but at least one digit)