GNU Info

Info Node: (guile.info)Match Structures

(guile.info)Match Structures


Next: Backslash Escapes Prev: Regexp Functions Up: Regular Expressions
Enter node , (file) or (file)node

Match Structures
----------------

A "match structure" is the object returned by `string-match' and
`regexp-exec'.  It describes which portion of a string, if any, matched
the given regular expression.  Match structures include: a reference to
the string that was checked for matches; the starting and ending
positions of the regexp match; and, if the regexp included any
parenthesized subexpressions, the starting and ending positions of each
submatch.

In each of the regexp match functions described below, the `match'
argument must be a match structure returned by a previous call to
`string-match' or `regexp-exec'.  Most of these functions return some
information about the original target string that was matched against a
regular expression; we will call that string TARGET for easy reference.

 - procedure: regexp-match? obj
     Return `#t' if OBJ is a match structure returned by a previous
     call to `regexp-exec', or `#f' otherwise.

 - procedure: match:substring match [n]
     Return the portion of TARGET matched by subexpression number N.
     Submatch 0 (the default) represents the entire regexp match.  If
     the regular expression as a whole matched, but the subexpression
     number N did not match, return `#f'.

 - procedure: match:start match [n]
     Return the starting position of submatch number N.

 - procedure: match:end match [n]
     Return the ending position of submatch number N.

 - procedure: match:prefix match
     Return the unmatched portion of TARGET preceding the regexp match.

 - procedure: match:suffix match
     Return the unmatched portion of TARGET following the regexp match.

 - procedure: match:count match
     Return the number of parenthesized subexpressions from MATCH.
     Note that the entire regular expression match itself counts as a
     subexpression, and failed submatches are included in the count.

 - procedure: match:string match
     Return the original TARGET string.


automatically generated by info2www version 1.2.2.9