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


8.4.5.1 match-string

Function: match-string count &optional in-string
COUNT

if zero, return the entire matched text; if positive integer, return the COUNTth matched parenthetical subexpression.

IN-STRING

If the last such operation was done against a string with string-match, then you should pass the same string as the argument IN-STRING.

After a buffer search or match, you should omit IN-STRING or pass ‘nil’ for it; but you should make sure that the current buffer when you call match-string is the one in which you did the searching or matching.

RETURN VALUE

The matched text or a portion of the matched text as a string depending on the value of COUNT.

The value is ‘nil’ if COUNT is out of range, or for a subexpression inside a ‘\|’ alternative that wasn’t used or a repetition that repeated zero times.