Previous: , Up: CL-PPCRE Basic Operations   [Contents][Index] Extracting information


The scan-to-strings function is similar to scan but returns substrings of ‘target-string’ instead of positions. This function returns two values on success: the whole match as a string plus an array of substrings (or =NIL=s) corresponding to the matched registers.


The register-groups-bind function tries to match the given pattern against the target string and binds matching fragments with the given variables.

(ppcre:register-groups-bind (first second third fourth)
      ("((a)|(b)|(c))+" "abababc" :sharedp t)
    (list first second third fourth))
;; => ("c" "a" "b" "c")

CL-PPCRE also provides a shortcut for calling a function before assigning the matching fragment to the variable:

(ppcre:register-groups-bind (fname lname (#'parse-integer date month year))
      ("(\\w+)\\s+(\\w+)\\s+(\\d{1,2})\\.(\\d{1,2})\\.(\\d{4})" "Frank Zappa 21.12.1940")
    (list fname lname (encode-universal-time 0 0 0 date month year 0)))
;; => ("Frank" "Zappa" 1292889600)