Next: , Previous: , Up: Accessing Matched Text Using Match Data   [Index]


8.4.5.5 match-data

Function: match-data &optional integers reuse reseat

This function returns a list of positions (markers or integers) that record all the information on the text that the last search matched.

RETURN VALUE
  • Element zero is the position of the beginning of the match for the whole expression;
  • element one is the position of the end of the match for the expression.
  • The next two elements are the positions of the beginning and end of the match for the first subexpression, and so on.
  • In general, element number 2N corresponds to ‘(match-beginning N)’; and

element number 2N + 1 corresponds to ‘(match-end N)’.

INTEGERS

Applies only to buffer searches; normally all the elements are markers or ‘nil’, but if INTEGERS is non-‘nil’, that means to use integers instead of markers. (In that case, the buffer itself is appended as an additional element at the end of the list, to facilitate complete restoration of the match data.)

REUSE

If REUSE is non-‘nil’, it should be a list. In that case, ‘match-data’ stores the match data in REUSE. REUSE is destructively modified. The purpose of this feature is to reduce the need for garbage collection.

RESEAT

If RESEAT is non-‘nil’, all markers on the REUSE list are reseated to point to nowhere.