regex match only 5 numbers code example Example 1: regex 10 numbers only @"^\d{10}$" Example 2: regex pater for only 4 or 6 digits ^([0-9]{4}|[0-9]{6})$