From Wikibooks, open books for an open world
Jump to navigation Jump to search
Template documentation[create]

This template can be called from the regex chapter of several books.

Usual regular expressions
Character Type Explanation
. Dot any character
[...] Brackets character class: all the enumerated characters in the class
[^...] Brackets and circumflex complemented class: all the characters except for the enumerated ones
^ Circumflex string or line start
$ Dollar string or line end
| Pipe alternative
(...) Parenthesis capture group: also used to limit the range of an alternative
* Asterisk 0, 1 or several occurrences
+ Plus 1 or several occurrences
? Interrogation 0 or 1 occurrence
POSIX characters classes[1]
Classe Signification
[[:alpha:]] any letter
[[:digit:]] any digit
[[:xdigit:]] hexadecimal characters
[[:alnum:]] any letter or digit
[[:space:]] any white space
[[:punct:]] any punctuation letter
[[:lower:]] any small cap letter
[[:upper:]] any capital letter
[[:blank:]] space or tabulation
[[:graph:]] displayable et printable characters
[[:cntrl:]] escaping characters
[[:print:]] printable characters, except for the control ones
Unicode regex[2]
Expression Signification
\A String start
\b Start or end of word character
\d Digit
\D Non digit
\s Space characters
\S Non space characters
\w Letter, digit or underscore
\W Non letter, digit or underscore character
\X Unicode character
\z String end

Debugger: https://regex101.com/

  1. https://www.regular-expressions.info/posixbrackets.html
  2. http://www.regular-expressions.info/unicode.html