regex only letters and numbers code example Example 1: regex for number and letters let regex = /[^A-Za-z0-9]+/ Example 2: regex 10 numbers only @"^\d{10}$"