A regular expression (commonly shortened to regex) is a sequence of characters that defines a search pattern. They are used to find, match, validate, and manipulate text based on rules rather than exact values. Instead of checking if a string equals something specific, regex lets you check if a string matches a pattern — like "does this look like an email address" or "find every word that starts with a capital letter."
Regex can look intimidating at first because of its dense symbolic syntax, but it is built from a small set of rules that combine together. A few common symbols worth knowing upfront:
. matches any single character
* means zero or more of the previous
+ means one or more of the previous
? means zero or one of the previous
^ means start of string
$ means end of string
\d matches any digit (0-9)
\w matches any word character (letters, digits, underscore)
\s matches any whitespace
[abc] matches any character inside the brackets
(abc) groups characters together
Regex is one of those tools that feels obscure until suddenly you need it, at which point it becomes invaluable. It is also one of the few areas where the pattern syntax itself is almost identical across all languages — the differences are mainly in how you call it.