_findre(haystack: text, needle: text, start: int = 0, line_by_line: bool = FALSE): list(int)

[The _findre primitive function was introduced in eval/95. Though some people are using it, it is not yet available in any major or minor Vesta release.]

Attempts to find matches to the regular expression needle in haystack that begins at or after position start. Returns the boolean value FALSE if there was no match, otherwise returns a list of lists. The fist element of the list is a list of the start and end offsets in haystack of the matching substring. Each of the additional list elements is the starting and ending offsets of matches of parenthisied sub-expressions. See examples below.

If start is less then 0, it is applied from the end of the string.

If line_by_line is TRUE then the match-any-character (.) will not match the newline character (\n).

_findre() makes use of POSIX extended regular expressions.  See the regex(7) man page for a complete description of the regular expression syntax.

_findre("this is a long string", "foobar") == FALSE
_findre("and this is a long string", "th(is)") == < < 4, 8 >, < 6, 8 > >
_findre("this is a long string", "th(is) (not)*") == < < 0, 5 >, < 2, 4 >, < -1, -1 > >
_findre("this string\nhas a newline", "string.has", 0, TRUE) == FALSE
_findre("this string\nhas a newline", "string.has", 0, FALSE) == < < 5, 15 > >
_findre("one last example at last", "last", 5) == < < 20, 24 > >

Scott Venier <scott@scooter.cx> / Primitive Functions / Vesta SDL Programmer's Reference