Next: , Previous: , Up: Searching and Matching   [Contents][Index]


44.4 POSIX Regular Expression Searching

The usual regular expression functions do backtracking when necessary to handle the ‘\|’ and repetition constructs, but they continue this only until they find some match. Then they succeed and report the first match found.

This section describes alternative search functions which perform the full backtracking specified by the POSIX standard for regular expression matching. They continue backtracking until they have tried all possibilities and found all matches, so they can report the longest match, as required by POSIX. This is much slower, so use these functions only when you really need the longest match.

In Emacs versions prior to 19.29, these functions did not exist, and the functions described above implemented full POSIX backtracking.

Command: posix-search-forward regexp &optional limit noerror count buffer

This is like re-search-forward except that it performs the full backtracking specified by the POSIX standard for regular expression matching.

Command: posix-search-backward regexp &optional limit noerror count buffer

This is like re-search-backward except that it performs the full backtracking specified by the POSIX standard for regular expression matching.

Function: posix-looking-at regexp &optional buffer

This is like looking-at except that it performs the full backtracking specified by the POSIX standard for regular expression matching.

Function: posix-string-match regexp string &optional start buffer

This is like string-match except that it performs the full backtracking specified by the POSIX standard for regular expression matching.

Optional arg buffer controls how case folding is done (according to the value of case-fold-search in buffer and buffer’s case tables) and defaults to the current buffer.


Next: , Previous: , Up: Searching and Matching   [Contents][Index]