Next: , Previous: , Up: irregex   [Index]


50.8 Supported PCRE syntax

Since the PCRE syntax is so overwhelming complex, it’s easier to just list what (vicare irregex) does not support for now. Refer to the PCRE documentation for details.18

Other than that, everything should work, including named submatches, zero–width assertions, conditional patterns, etc.

In addition, \< and \> act as beginning–of–word and end–of–word marks, respectively, as in Emacs regular expressions.

Also, two escapes are provided to embed SRE patterns inside PCRE strings, "\'<sre>" and "(*'<sre>)". For example, to match a comma–delimited list of integers we could use:

"\\'integer(,\\'integer)*"

and to match a URL in angle brackets we could use:

"<('*http-url)>"

note in the second example the enclosing "('*...)" syntax is needed because the Scheme reader would consider the closing ‘>’ as part of the SRE symbol.

The following chart gives a quick reference from PCRE form to the SRE equivalent:

;; basic syntax
"^"                     ;; bos (or eos inside (?m: ...))
"$"                     ;; eos (or eos inside (?m: ...))
"."                     ;; nonl
"a?"                    ;; (? a)
"a*"                    ;; (* a)
"a+"                    ;; (+ a)
"a??"                   ;; (?? a)
"a*?"                   ;; (*? a)
"a+?"                   ;; (+? a)
"a{n,m}"                ;; (** n m a)

;; grouping
"(...)"                 ;; (submatch ...)
"(?:...)"               ;; (: ...)
"(?i:...)"              ;; (w/nocase ...)
"(?-i:...)"             ;; (w/case ...)
"(?<name>...)"          ;; (=> <name>...)

;; character classes
"[aeiou]"               ;; ("aeiou")
"[^aeiou]"              ;; (~ "aeiou")
"[a-z]"                 ;; (/ "az") or (/ "a" "z")
"[[:alpha:]]"           ;; alpha

;; assertions
"(?=...)"               ;; (look-ahead ...)
"(?!...)"               ;; (neg-look-ahead ...)
"(?<=...)"              ;; (look-behind ...)
"(?<!...)"              ;; (neg-look-behind ...)
"(?(test)pass|fail)"    ;; (if test pass fail)
"(*COMMIT)"             ;; commit

Footnotes

(18)

See http://pcre.org/pcre.txt. URL last verified Sun Jul 12, 2009.


Next: , Previous: , Up: irregex   [Index]