Next: , Up: irregex sre   [Index]


50.9.1 Syntax tables

The following tables summarizes the SRE syntax, with detailed explanations following.

;; basic patterns
<string>                          ; literal string
(seq <sre> ...)                   ; sequence
(: <sre> ...)
(or <sre> ...)                    ; alternation

;; optional/multiple patterns
(? <sre> ...)                     ; 0 or 1 matches
(* <sre> ...)                     ; 0 or more matches
(+ <sre> ...)                     ; 1 or more matches
(= <n> <sre> ...)                 ; exactly <n> matches
(>= <n> <sre> ...)                ; <n> or more matches
(** <from> <to> <sre> ...)        ; <n> to <m> matches
(?? <sre> ...)                    ; non-greedy (non-greedy) pattern: (0 or 1)
(*? <sre> ...)                    ; non-greedy kleene star
(**? <from> <to> <sre> ...)       ; non-greedy range

;; submatch patterns
(submatch <sre> ...)              ; numbered submatch
($ <sre> ...)
(submatch-named <name> <sre> ...) ; named submatch
(=> <name> <sre> ...)
(backref <n-or-name>)             ; match a previous submatch

;; toggling case-sensitivity
(w/case <sre> ...)                ; enclosed <sre>s are case-sensitive
(w/nocase <sre> ...)              ; enclosed <sre>s are case-insensitive

;; character sets
<char>                            ; singleton char set
(<string>)                        ; set of chars
(or <cset-sre> ...)               ; set union
(~ <cset-sre> ...)                ; set complement (i.e. [^...])
(- <cset-sre> ...)                ; set difference
(& <cset-sre> ...)                ; set intersection
(/ <range-spec> ...)              ; pairs of chars as ranges

;; named character sets
any
nonl
ascii
lower-case     lower
upper-case     upper
alphabetic     alpha
numeric        num
alphanumeric   alphanum  alnum
punctuation    punct
graphic        graph
whitespace     white     space
printing       print
control        cntrl
hex-digit      xdigit

;; assertions and conditionals
bos eos                           ; beginning/end of string
bol eol                           ; beginning/end of line
bow eow                           ; beginning/end of word
nwb                               ; non-word-boundary
(look-ahead <sre> ...)            ; zero-width look-ahead assertion
(look-behind <sre> ...)           ; zero-width look-behind assertion
(neg-look-ahead <sre> ...)        ; zero-width negative look-ahead assertion
(neg-look-behind <sre> ...)       ; zero-width negative look-behind assertion
(atomic <sre> ...)                ; for (?>...) independent patterns
(if <test> <pass> [<fail>])       ; conditional patterns
commit                            ; don't backtrack beyond this (i.e. cut)

;; backwards compatibility
(posix-string <string>)           ; embed a POSIX string literal