Please note that this wont work; regex’s match substrings, so although your regex requires 9 characters (“[...]{9}
”) it will also match a phone number with 10, 11, or 1000 numbers - because it will still successfully find a substring of exactly 9 digits.
Typically when using regex-based constraint checking you want to check the entire string (and nothing less), so in most cases you will want to surround your regex with ‘^
’ - start of string - and '$'
- end of string, as @stephanealoo has done.