Code challenges that involve the use of regular expressions.

Regular expressions (often abbreviated as regex or regexp) are a language of strings to match other strings. This is a tutorial for regular expressions, but since different programming languages have different regular expression syntax, be sure to check out the tutorial for your specific language.

Tutorials:

Regex styles:

Popular Tools:

Regex-based programming languages:

General syntax:

Regex works character by character. There is a list of metacharacters which do something special. All other characters match the sequence of characters in the order they are in. For example: match would match any string with a substring of match. Metacharacters (may vary from language to language):

+----+------------------------------------------------------+
| .  | A match-all; it matches any character                |
+----+------------------------------------------------------+
| |  | Alternation: attempts to match the regex on the left |
|    |              or, if that fails, the one on the right |
+----+------------------------------------------------------+
| () | Used to signify groups                               |
+----+------------------------------------------------------+
| [] | Used to indicate character classes. Inside these,    |
|    | many metacharacters don't need to be escaped         |
+----+------------------------------------------------------+
| -  | Only a metacharacter inside []s, indicates a range   |
+----+------------------------------------------------------+
| \  | Used to escape special characters, including these   |
+----+------------------------------------------------------+
| ^  | Used to indicate the start of a string               |
+----+------------------------------------------------------+
| $  | Used to indicate the end of a string                 |
+----+------------------------------------------------------+
| *  | Used to indicate group repetition of 0 or more times |
+----+------------------------------------------------------+
| +  | Used to indicate group repetition of 1 or more times |
+----+------------------------------------------------------+
| ?  | Used to indicate group repetition of 1 or 0 times    |
|    | Additionally may be used for special flags/look-foos |
+----+------------------------------------------------------+
| {} | Used to indicate group repetition of varying times   |
+----+------------------------------------------------------+
history | excerpt history