# regex

Contains rules for string processing using regular expressions.

- `"x*"` matches the pattern `"x"` zero or more times.

- `"x+"` matches `"x"` one or more times.

- `"x?"` matches `"x"` zero or one time.

- `"[abcd]"` matches any of the characters, `"a"`, `"b"`, `"c"`, and `"d"`. A character range such as `"[a-z]"` matches any character between `"a"` and `"z"`. `"[^abc]"` matches any character which is not `"a"`, `"b"`, or `"c"`.

- `"x|y"` matches either pattern `"x"` or pattern `"y"`

- `(x)` matches `"x"` and captures it.

- `"^"` matches the beginning of the string.

- `"$"` matches the end of the string.

- "\<" matches the beginning of a word.

- "\>" matches the end of a word.

1. `rule split ( string separator )`

   Returns a list of the following substrings:

   1. from beginning till the first occurrence of `separator` or till the end,

   2. between each occurrence of `separator` and the next occurrence,

   3. from the last occurrence of `separator` till the end.

   If no separator is present, the result will contain only one element.
2. `rule split-list ( list * : separator )`

   Returns the concatenated results of applying regex.split to every element of the list using the separator pattern.

3. `rule match ( pattern : string : indices * )`

   Match `string` against `pattern`, and return the elements indicated by `indices`.

4. `rule transform ( list * : pattern : indices * )`

   Matches all elements of `list` against the `pattern` and returns a list of elements indicated by `indices` of all successful matches. If `indices` is omitted returns a list of first parenthesized groups of all successful matches.

5. `rule escape ( string : symbols : escape-symbol )`

   Escapes all of the characters in `symbols` using the escape symbol `escape-symbol` for the given string, and returns the escaped string.

6. `rule replace ( string match replacement )`

   Replaces occurrences of a match string in a given string and returns the new string. The match string can be a regex expression.

7. `rule replace-list ( list * : match : replacement )`

   Replaces occurrences of a match string in a given list of strings and returns a list of new strings. The match string can be a regex expression.

See also: MATCH