Regsexp Procedures (MIT/GNU Scheme 10.1.1)

Previous: Regular S-Expressions, Up: Regular Expressions [Contents][Index]

#### 6.2.2 Regsexp Procedures

The regular s-expression implementation has two parts, like many other regular-expression implementations: a compiler that translates the pattern into an efficient form, and one or more procedures that use that pattern to match or search inputs.

procedure: compile-regsexp regsexp

  Compiles regsexp by translating it into a procedure that implements the specified matcher.

The match and search procedures each return a list when they are successful, and `#f` when they fail. The returned list is of the form `(s e register …)`, where s is the index at which the match starts, e is the index at which the match ends, and each register is a pair `(key . contents)` where key is the register’s name and contents is the contents of that register as a string.

In order to get reliable results, the string arguments to these procedures must be in Unicode Normalization Form C. The string implementation keeps most strings in this form by default; in other cases the caller must convert the string using `string->nfc`.

procedure: regsexp-match-string crse string [start [end]]

  The crse argument must be a value returned by `compile-regsexp`. The string argument must satisfy `string-in-nfc?`.

  Matches string against crse and returns the result.

procedure: regsexp-search-string-forward crse string [start [end]]

  The crse argument must be a value returned by `compile-regsexp`. The string argument must satisfy `string-in-nfc?`.

  Searches string from left to right for a match against crse and returns the result.