HTML Utilities

Showing help on 'rmatch()'

Syntax: match (STR <subject>, STR <pattern> [, <case-matters>]) => LIST
rmatch (STR <subject>, STR <pattern> [, <case-matters>]) => LIST

The function `match()' (`rmatch()') searches for the first (last) occurrence of the regular expression <pattern> in the string <subject>. If <pattern> is syntactically malformed, then E_INVARG is raised. The process of matching can in some cases consume a great deal of memory in the server; should this memory consumption become excessive, then the matching process is aborted and E_QUOTA is raised.

If no match is found, the empty list is returned; otherwise, these functions return a list containing information about the match (see below). By default, the search ignores upper/lower case distinctions. If <case-matters> is provided and true, then case is treated as significant in all comparisons.

The list that `match()' (`rmatch()') returns contains the details about the match made. The list is in the form:

{<start>, <end>, <replacements>, <subject>}

where <start> is the index in STRING of the beginning of the match, <end> is the index of the end of the match, <replacements> is a list described below, and <subject> is the same string that was given as the first argument to the `match()' or `rmatch()'.

The <replacements> list is always nine items long, each item itself being a list of two numbers, the start and end indices in <subject> matched by some parenthesized sub-pattern of <pattern>. The first item in <replacements> carries the indices for the first parenthesized sub-pattern, the second item carries those for the second sub-pattern, and so on. If there are fewer than nine parenthesized sub-patterns in <pattern>, or if some sub-pattern was not used in the match, then the corresponding item in <replacements> is the list {0, -1}. See the discussion of `%)' in `help regular-expressions', for more information on parenthesized sub-patterns.

match("foo", "f*o") => {1, 2, {{0, -1}, ...}, "foo"}
match("foo", "fo*") => {1, 3, {{0, -1}, ...}, "foo"}
match("foobar", "o*b") => {2, 4, {{0, -1}, ...}, "foobar"}
rmatch("foobar", "o*b") => {4, 4, {{0, -1}, ...}, "foobar"}
match("foobar", "f%(o*%)b") => {1, 4, {{2, 3}, {0, -1}, ...}, "foobar"}

See "help regular-expressions" for information on the syntax and semantics of patterns.



-- telnet://project-mongoose.net:7777 -- Mail us -- http://project-mongoose.net:7780/ --
-- Five users connected --