The perlre Reference Manual

Table of Contents

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

The perlre Reference Manual

This is the perlre Reference Manual, version 0.3, generated automatically by Declt version 2.3 "Robert April" on Tue Feb 20 09:09:55 2018 GMT+0.


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

1 Introduction

perlre

perl regular expression api - m// and s/// - for CL-PPCRE with CL-INTERPOL support

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

With let-over-lambda you can do:

perlre supports:

For now interpolation comes with a cost, here are some restrictions:

Examples:

(ql:quickload :perlre)


(#~s'(A)'*\1*'i "hanna")        ; => "h*a*nna"

(#~s'(A)'*\1*'ig "hanna")       ; => "h*a*nn*a*"

(#~s/"(a)"/"*\\1*"/ "hanna")    ; => "h*a*nna"

(#~s%"(a)"%"*\\1*"%g "hanna")   ; => "h*a*nn*a*"

(perlre:ifmatch (#~m/"(b)(c)(d)(e)"/ "abcdef") 
 (list $\` $& $\' $1 $2 $3 $4)) ; => ("a" "bcde" "f" "b" "c" "d" "e")

(perlre:whenmatch (#~m/"(b)(c)(d)(e)"/ "abcdef") 
  (print $\`) 
  (print $2) 
  (print $4))


------------
variable or function
------------

(let ((x "an")
      (y "AN"))
 (#~s/(format nil "~a" x)/(format nil "~a" y)/ "hanna")) ; => "hANna"

(let ((x "an")) 
 (pre:ifmatch (#~m/x/ "hanna") $&))                      ; => "an"

(let ((x "a(n)n")) 
 (pre:ifmatch (#~m/x/ "hanna") 
	(list $\` $& $\' $1)))                    ; => ("h" "ann" "a" "n")


------------
interpolation with cl-interpol
------------

(cl-interpol:enable-interpol-syntax)

(let ((x "(n)(n)"))
 (#~s/#?"${x}"/#?"\\1 \n\n \\2"/ "hanna"))

(let ((x "(n)(n)")
      (y "HANNA"))
 (#~s/#?"${x}"/#?"\\1 \n ${y} \n \\2"/ "hanna"))

(let ((x "an")) 
 (pre:ifmatch (#~m/#?"(${x})"/ "hanna") 
	(list $& $1)))

(cl-interpol:disable-interpol-syntax)

------------
with another quoting delimiter
------------

(#~s'(A)'*\1*'i "hanna")        ; => "h*a*nna"

(setf perlre::qd #\§)

(#~s§(A)§'\1'§i "hanna")        ; => "h'a'nna"


(setf perlre::qd #\') ; reset to default

------------
e modifier
------------
s///e  <-->  (ppcre:regex-replace . . . :simple-calls t)

(defun fn (s r1 r2) 
	(declare (ignore s))
	(format nil "~a : ~a " (string-upcase r1) (+ 3 (read-from-string r2))))

(ppcre:regex-replace "a(bc)(3)" "abc3e" #'fn :simple-calls t)

(#~s/"a(bc)(3)"/#'fn/e "abc3e")

------------
m//g
------------

(#~m'aB'gi "1ab2ab3ab4")   ; => '("ab" "ab" "ab"))

There is a test-file with more examples:

(prove:run #P"path-to/perlre/test.lisp")
``

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

2 Systems

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


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

2.1 perlre

Author

<schatzer.johann@gmail>

License

BSD Simplified — the same as let-over-lambda

Description

perl regular expression api - m// and s/// - for CL-PPCRE with CL-INTERPOL support

Version

0.3

Dependencies
Source

perlre.asd (file)

Components

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

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 files   [Contents][Index]

3.1.1 perlre.asd

Location

perlre.asd

Systems

perlre (system)


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

3.1.2 perlre/package.lisp

Parent

perlre (system)

Location

package.lisp

Packages

perlre


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

3.1.3 perlre/perlre.lisp

Dependency

package.lisp (file)

Parent

perlre (system)

Location

perlre.lisp

Exported Definitions
Internal Definitions

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

4 Packages

Packages are listed by definition order.


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

4.1 perlre

Source

package.lisp (file)

Nickname

pre

Use List

common-lisp

Exported Definitions
Internal Definitions

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

5 Definitions

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


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

5.1 Exported definitions


Previous: , Up: Exported definitions   [Contents][Index]

5.1.1 Macros

Macro: ifmatch (TEST O!S) CONSEQ &optional ALTERN
Package

perlre

Source

perlre.lisp (file)

Macro: whenmatch (TEST S) &rest CONSEQ
Package

perlre

Source

perlre.lisp (file)


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

5.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.1 Special variables

Special Variable: qd

quoting-delimiter

Package

perlre

Source

perlre.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.2 Macros

Macro: mat O!A O!M
Package

perlre

Source

perlre.lisp (file)

Macro: sub O!A O!M
Package

perlre

Source

perlre.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

5.2.3 Functions

Function: mods S

imsxg modifiers

Package

perlre

Source

perlre.lisp (file)

Function: segment-reader S C N

to supress string interpolation use single-quote delimiters, #~s”’, #~m”, as in perl, see camelbook page 192, or use an alternate quoting-delimiter doing e.g. (setf perlre::qd #!)

Package

perlre

Source

perlre.lisp (file)


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

Appendix A Indexes


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

A.1 Concepts

Jump to:   F   L   P  
Index Entry  Section

F
File, Lisp, perlre.asd: The perlre<dot>asd file
File, Lisp, perlre/package.lisp: The perlre/package<dot>lisp file
File, Lisp, perlre/perlre.lisp: The perlre/perlre<dot>lisp file

L
Lisp File, perlre.asd: The perlre<dot>asd file
Lisp File, perlre/package.lisp: The perlre/package<dot>lisp file
Lisp File, perlre/perlre.lisp: The perlre/perlre<dot>lisp file

P
perlre.asd: The perlre<dot>asd file
perlre/package.lisp: The perlre/package<dot>lisp file
perlre/perlre.lisp: The perlre/perlre<dot>lisp file

Jump to:   F   L   P  

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

A.2 Functions

Jump to:   F   I   M   S   W  
Index Entry  Section

F
Function, mods: Internal functions
Function, segment-reader: Internal functions

I
ifmatch: Exported macros

M
Macro, ifmatch: Exported macros
Macro, mat: Internal macros
Macro, sub: Internal macros
Macro, whenmatch: Exported macros
mat: Internal macros
mods: Internal functions

S
segment-reader: Internal functions
sub: Internal macros

W
whenmatch: Exported macros

Jump to:   F   I   M   S   W  

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

A.3 Variables

Jump to:   Q   S  
Index Entry  Section

Q
qd: Internal special variables

S
Special Variable, qd: Internal special variables

Jump to:   Q   S  

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

A.4 Data types

Jump to:   P   S  
Index Entry  Section

P
Package, perlre: The perlre package
perlre: The perlre system
perlre: The perlre package

S
System, perlre: The perlre system

Jump to:   P   S