Basic Syntax Flashcards
Learn basic regular expression syntax! Much of this information is provided by http://www.regular-expressions.info/reference.html
\Q…\E
For example: \Q+-*/\E
Matches the characters literally, suppressing the meaning of special characters.
For example, match +-*/
\a
Matches the bell character
\e
Matches the escape character
\f
Matches the form feed character
\v
Matches the vertical tab character
[ ]
Symbol(s) used to encapsulate a character class. A character class matches a single character out of all the possibilities offered by the character class.
^ immediately following a [
Negates the character class, causing it to match a single character not listed in the character class.
\d
Matches a digit
\w
Matches word characters (letters, digits and underscores)
\s
Matches whitespace (spaces, tabs and linebreaks)
\D
Matches a character that is not a digit
\W
Matches a character that is not a word character (letters, digits, and underscores)
\S
Matches a character that is not a whitespace
\b
Matches a backspace character (inside a character class [ ] )
\t
Matches a tab character (inside a character class [ ] )
. (dot)
Matches any single character except line break characters
\n
Matches a line break character
Matches at the start of the string the regex pattern is applied to
$
Matches at the end of the string the regex pattern is applied to.
\b
Matches at the position between a word character (anything matched by \w) and a non-word character (anything matched by [^\w] or \W) as well as at the start and/or end of the string if the first and/or last characters in the string are word characters.
\B
Matches at the position between two word characters (i.e the position between \w\w) as well as at the position between two non-word characters (i.e. \W\W).
(pipe)
Causes the regex engine to match either the part on the left side.
?
Makes the preceding item optional.
*
Repeats the previous item zero or more times.