Buy the book!
|[ < ]||[ > ]||[ << ]||[ Up ]||[ >> ]||[Top]||[Contents]||[Index]||[ ? ]|
Searching means trying to match starting at successive positions
within a string. The function
re_search does this.
re_search, you must compile your regular
expression. See section 7.1.2 GNU Regular Expression Compiling.
Here is the function declaration:
int re_search (struct re_pattern_buffer *pattern_buffer, const char *string, const int size, const int start, const int range, struct re_registers *regs)
whose arguments are the same as those to
re_match (see section 7.1.3 GNU Matching) except that the two arguments start and range
re_match's argument start.
If range is positive, then
re_search attempts a match
starting first at index start, then at start + 1 if
that fails, and so on, up to start + range; if
range is negative, then it attempts a match starting first at
index start, then at start -1 if that fails, and so
If start is not between zero and size, then
returns -1. When range is positive,
adjusts range so that start + range - 1 is
between zero and size, if necessary; that way it won't search
outside of string. Similarly, when range is negative,
re_search adjusts range so that start +
range + 1 is between zero and size, if necessary.
fastmap field of pattern_buffer is zero,
re_search matches starting at consecutive positions; otherwise,
fastmap to make the search more efficient.
See section 7.1.6 Searching with Fastmaps.
If no match is found,
re_search returns -1. If
a match is found, it returns the index where the match began. If an
internal error happens, it returns -2.
|webmaster donations bookstore||delorie software privacy|
|Copyright © 2003 by The Free Software Foundation||Updated Jun 2003|