Next: , Up: Regular Expression Searching in Programs   [Index]


8.4.3.1 re-search-forward

Function: re-search-forward regexp &optional limit noerror count

This function searches forward in the current buffer for a string of text that is matched by the regular expression REGEXP. The function skips over any amount of text that is not matched by REGEXP, and leaves point at the end of the first match found. It returns the new value of point.

REGEXP

The regexp to match against

LIMIT

The upper bound to the search, unless nil

NOERROR

What ‘re-search-forward’ does when the search fails depends on the value of NOERROR:

nil

Signal a ‘search-failed’ error.

t

Do nothing and return ‘nil’.

other

Move point to LIMIT (or the end of the accessible portion of the buffer) and return ‘nil’.

COUNT

If COUNT is positive number, N, search N times. If all searches succeed, function call succeeds, moves point and return point’s new value. Otherwise, function call fails.

If COUNT is a negative number -N, the search is done N times in the backward direction.

RETURN VALUE

Upon success, the value of point; nil on failure.