elisp: Match Data

 
 33.6 The Match Data
 ===================
 
 Emacs keeps track of the start and end positions of the segments of text
 found during a search; this is called the “match data”.  Thanks to the
 match data, you can search for a complex pattern, such as a date in a
 mail message, and then extract parts of the match under control of the
 pattern.
 
    Because the match data normally describe the most recent search only,
 you must be careful not to do another search inadvertently between the
 search you wish to refer back to and the use of the match data.  If you
 can’t avoid another intervening search, you must save and restore the
 match data around it, to prevent it from being overwritten.
 
    Notice that all functions are allowed to overwrite the match data
 unless they’re explicitly documented not to do so.  A consequence is
 that functions that are run implicitly in the background (See
 Timers, and SeeIdle Timers) should likely save and restore the
 match data explicitly.
 

Menu