Next: , Previous: , Up: Searching and Replacing   [Index]


8.4.5 Accessing Matched Text Using Match Data

This section explains how to use the match data to find out what was matched by the last search or match operation, if it succeeded.

Every successful search sets the match data. You should query the match data immediately after searching, before calling any other function that might perform another search, or save and restore the match data around the call to functions that could perform another search, or use the functions that explicitly do not modify the match data.

You can ask about the entire matching text, or about a particular parenthetical subexpression of a regular expression, using the COUNT argument.