chickadee » chicken » irregex » irregex-search

Searches for any instances of the pattern <irx> (a POSIX string, SRE sexp, or pre-compiled regular expression) in <str>, optionally between the given range. If a match is found, returns a match object, otherwise returns #f.

Match objects can be used to query the original range of the string or its submatches using the irregex-match-* procedures below.

Examples:

(irregex-search "foobar" "abcFOOBARdef") => #f

(irregex-search (irregex "foobar" 'i) "abcFOOBARdef") => #<match>

(irregex-search '(w/nocase "foobar") "abcFOOBARdef") => #<match>

Note, the actual match result is represented by a vector in the default implementation. Throughout this manual, we'll just write #<match> to show that a successful match was returned when the details are not important.

Matching follows the POSIX leftmost, longest semantics, when searching. That is, of all possible matches in the string, irregex-search will return the match at the first position (leftmost). If multiple matches are possible from that same first position, the longest match is returned.