Regular Expressions

The :std/pregexp library provides the Dorai Sitaram's well known portable Scheme regular expression library.

See the pregexp page for details of the regular expression language and examples.

usage

(import :std/pregexp)

pregexp

usage

(pregexp regexp)
  regexp := string; the regular expression
=> <pregexp>

Parse a string and compile it to a regular expression.

pregexp-match

usage

(pregexp-match pat str [start #f] [end #f])
  pat := <pregexp> or string; the regular expression to match
  str := the string to match
  start := start position in the string
  end := end position in the string
=> list or #f

Match a string against a regular expression and return a list of matching substrings.

pregexp-match-positions

usage

(pregexp-match-positions pat str [start #f] [end #f])
  pat := <pregexp> or string; the regular expression to match
  str := the string to match
  start := start position in the string
  end := end position in the string
=> list or #f

Match a string against a regular expression and return a list of index pairs where matches have occured.

pregexp-split

usage

(pregexp-split pat str)
  pat := <pregexp> or string; the regular expression to match
  str := the string to match
=> list

Split a string using a regular expression as delimiter and return a list of matching substrings.

pregexp-replace

usage

(pregexp-replace pat str ins)
  pat := <pregexp> or string; the regular expression to match
  str := the string to match
  ins := the string to insert
=> string

Replace the portion of a string matched by regular expression with another string.

pregexp-replace*

usage

(pregexp-replace* pat str ins)
  pat := <pregexp> or string; the regular expression to match
  str := the string to match
  ins := the string to insert
=> string

Like pregexp-replace but replaces all occurences of hte pattern

pregexp-quote

usage

(pregexp-quote str)
  str := a string
=> string

Takes an arbitrary string and returns a string regular expression that represents it precisely.