Regular Expressions, JSON and Data Formats
(ql:quickload '("cl-ppcre" "com.inuoe.jzon" "cl-csv" "local-time"))
;; cl-ppcre: Perl-compatible regular expressions (fast, pure Lisp)
(cl-ppcre:scan "\\d+" "abc 123") ; 4, 7, #(), #()
(cl-ppcre:scan-to-strings "(\\d{4})-(\\d{2})" "on 2025-10") ; "2025-10", #("2025" "10")
(cl-ppcre:all-matches-as-strings "\\w+" "hello big world") ; ("hello" "big" "world")
(cl-ppcre:regex-replace-all "o" "foo boo" "0") ; "f00 b00"
(cl-ppcre:regex-replace "(\\w+) (\\w+)" "hello world" "\\2 \\1") ; "world hello"
(cl-ppcre:split "\\s*,\\s*" "a , b,c") ; ("a" "b" "c")
(cl-ppcre:register-groups-bind (year month) ("(\\d{4})-(\\d{2})" "2025-10")
(list (parse-integer year) (parse-integer month))) ; (2025 10)
(cl-ppcre:do-matches-as-strings (m "\\d+" "1 22 333") (print m))
;; S-expression regex syntax:
(cl-ppcre:scan '(:sequence :start-anchor (:greedy-repetition 1 nil :digit-class) :end-anchor) "123")
;; JSON with jzon
(com.inuoe.jzon:parse "{\"name\": \"Ana\", \"tags\": [\"lisp\"], \"age\": 30}") ; → a hash table
(let ((obj (com.inuoe.jzon:parse "{\"x\": [1, 2, 3]}")))
(gethash "x" obj)) ; #(1 2 3)
(com.inuoe.jzon:strin
…