Regular Expression (Regex)
A regular expression (regex) is a pattern of characters that describes a set of strings. Programs use regular expressions to search text, check whether input matches a format (such as an email address, phone number or PIN code), extract parts of text, and find and replace.
Special characters give the pattern its power: . matches any character, \d a digit, \w a word character, * means zero or more, + one or more, ? optional, [abc] any one of a set, ^ and $ the start and end of the text, and parentheses create groups. Almost every programming language and text editor supports regular expressions.
^\d{6}$ 6-digit Indian PIN code
^[6-9]\d{9}$ 10-digit Indian mobile number
^[\w.+-]+@[\w-]+\.[\w.]+$ simple email check
\b\d{4}-\d{2}-\d{2}\b date such as 2026-10-25