The perlre Reference Manual

Next: , Previous: , Up: (dir)   [Contents][Index]

The perlre Reference Manual

This is the perlre Reference Manual, version 0.5, generated automatically by Declt version 4.0 beta 2 "William Riker" on Tue Nov 15 06:52:45 2022 GMT+0.

Table of Contents


1 Introduction

perlre

Regular expression API using CL-PPCRE and CL-INTERPOL with operators known from sed or perl, m// and s/// plus a similar one, d// for split.

Can be useful for code brevity in regex heavy programs.

idea and code from Doug Hoyte's book Let Over Lambda and quicklisp-package let-over-lambda

Synopsis:

1)
(set-dispatch-macro-character #\# #\~ 'perlre:|#~-reader|)

2)
(#~s/regex/substitution/imsxge string)
(#~m/regex/[modifier] string)
(#~d/regex/[modifier] string) 

(ifmatch test then else)
(whenmatch test conseq*)
(match string clause*) ; a clause (test conseq) e.g (#~m/(regex)/ (list $1))


Some examples:

  ; output of both is "h*a*nn*a*" 
  (let ((stg "hanna")
        (reg "(A)")
        (sub "*\\1*"))

    ; perlre
    (#~s/reg/sub/ig stg)

    ; cl-ppcre
    (ppcre:regex-replace-all (ppcre:create-scanner reg :case-insensitive-mode t) stg sub))
  



  ; -> 2
  (match "2012-11-04" 
    (#~m'abc' 1)
    (t 2))

  ;    HELLO
  ; -> 2016
  (match "2012-11-04" 
    (#~m'abc' 1)
    (#~m§(2012)-11-(04)§ (print 'hello) (+ (parse-integer $1) (parse-integer $2)))
    (t 2))

  ;"04/2012"
  (pre:match "2012-11-04"
    (#~m'abc' 1)
    (#~m§(\d{4})-.+-(..)§ (format nil "~a/~a" $2 $1))
    (t 2))

See test.lisp for other examples.

;;;; 1.5.19 ;;;;;;;;; vim syntax/color in ~/.vim/sytax/lisp.vim I have this regex to see the whole expressin in green syn match lispPerlre "#~s(.).{-}\1.{-}\1\w*" and hi lispPerlre ctermfg=green in ./vim/colors/self.vim

in vimre syntyx co


2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 perlre

s///, m//, d// - regular expression API for CL-PPCRE and CL-INTERPOL

Author

<schatzer.johann@gmail>

License

BSD Simplified — the same as let-over-lambda

Version

0.5

Dependencies
  • cl-ppcre (system).
  • cl-interpol (system).
  • let-over-lambda (system).
  • prove (system).
  • trivia (system).
  • trivia.ppcre (system).
Source

perlre.asd.

Child Components

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp   [Contents][Index]

3.1.1 perlre/perlre.asd

Source

perlre.asd.

Parent Component

perlre (system).

ASDF Systems

perlre.


3.1.2 perlre/package.lisp

Source

perlre.asd.

Parent Component

perlre (system).

Packages

perlre.


Previous: , Up: Lisp   [Contents][Index]

3.1.3 perlre/perlre.lisp

Dependency

package.lisp (file).

Source

perlre.asd.

Parent Component

perlre (system).

Public Interface
Internals

4 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

4.1 perlre

Source

package.lisp.

Nickname

pre

Use List

common-lisp.

Public Interface
Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Public Interface


5.1.1 Macros

Macro: ifmatch ((test o!s) conseq &optional altern)
Package

perlre.

Source

perlre.lisp.

Macro: match (stg &body clauses)
Package

perlre.

Source

perlre.lisp.

Macro: whenmatch ((test s) &rest conseq)
Package

perlre.

Source

perlre.lisp.


Previous: , Up: Public Interface   [Contents][Index]

5.1.2 Ordinary functions

Function: #~-reader (s c n)
Package

perlre.

Source

perlre.lisp.


5.2 Internals


Next: , Previous: , Up: Internals   [Contents][Index]

5.2.1 Macros

Macro: div (o!a o!m)
Package

perlre.

Source

perlre.lisp.

Macro: mat (o!a o!m)
Package

perlre.

Source

perlre.lisp.

Macro: sub (o!a o!m)
Package

perlre.

Source

perlre.lisp.


Previous: , Up: Internals   [Contents][Index]

5.2.2 Ordinary functions

Function: mods (s)

modifiers: i m s x g e r and digits

Package

perlre.

Source

perlre.lisp.

Function: segment-reader (s c n)

evaluation with / / delimiters, no evaluation with any other corresponding delimiter

Package

perlre.

Source

perlre.lisp.


Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts


Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables