Next: , Up: CL-PPCRE Basic Operations   [Contents][Index]


4.1.1.1 Scan Functions—Looking for matching patterns

scan

The scan function tries to match the given pattern and on success returns four multiple-values values:

  1. the start of the match
  2. the end of the match
  3. array denoting the beginnings of register matches
  4. array denoting the endings of register matches

Returns ‘NIL’ on failure.

create-scanner

A regular expression pattern can be compiled with the create-scanner function call. A “scanner” will be created that can be used by other functions.

(let ((ptrn (ppcre:create-scanner "(a)*b")))
  (ppcre:scan ptrn "xaaabd"))

will yield the same results as:

(ppcre:scan "(a)*b" "xaaabd")

but will require less time for repeated scan calls as parsing the expression and compiling it is done only once.