grel general expression character classes code example
Example 1: grel general expression character classes
\p{L} - letter
\p{P} - punctuation
\p{InBasicLatin} - in basic Latin Unicode block
\p{InArabic} - in Arabic Unicode block
Example 2: grel general expression character classes
. any character (almost*)
\ escape character
| or
\A or ^ anchor: start of string
\Z or $ anchor: end of string
[] list or range to be matched
[^] negative list or range (NOT these characters)
Example 3: grel general expression character classes
* metacharacters
* character escapes \
* anchors \A\Z or ^$
* character classes [][^]
* quantifiers *?+{min,max}
* grouping ()
* substitutions $1 or \1
Example 4: grel general expression character classes
\d any digit
\D any non-digit
\w any word character [a-zA-Z0-9_]
\W any non-word char. [^a-zA-Z0-9_]
\s any whitespace char.
\S any non-whitespace char.
\t tab
\n newline
\r carriage return