Regular expressions are a declarative language, mainly used for pattern matching within strings. Please include a tag specifying the programming language you are using, together with this tag.
Regular and Irregular Expressions
Regular expressions are a powerful form of declarative programming language, mainly used for pattern matching within strings. Students of computer science know them as the user-friendly face to the abstruse field of finite automata. The rest of us think of them as string matching using wildcards.
There are many different dialects of regular expressions, all subtly different. Therefore, when asking questions, always include the specific programming language or tool (e.g., Perl, Ruby, Python, Java, JavaScript, vi, emacs, sed, lex, grep, etc.) you are using. Otherwise you may get answers that won’t work for you.
Depending on which flavor you’re using, modern regular expressions can allow backreferences, conditional subpatterns, regex subroutines, code callouts, positive and negative lookahead/lookbehind assertions, and even recursion. This rich feature set allows them to parse far more than the strictly regular languages for which they were originally named. Today we still call these pattern-matching languages regular expressions (or regexes for short), even though the reg- part is little more than an historical artifact which no longer applies.