regex expression for text and numbers only code example Example: regex for numbers Regex regex = new Regex(@"^\d$");