[The _findre primitive function first became officially available in release/12.pre13/13.]
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 of integers. 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.
_findre() makes use of the Perl Compatible Regular Expression library. See the perlre 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("abbbbc", "a(((b){2}){2})c")) == < < 0, 6 >, < 1, 5 >, < 3, 5 >, < 4, 5 > > _findre("one last example at last", "last", 5) == < < 20, 24 > >
Note that if you want to use a backslash in a regular expression (e.g. for escaping a character with special meaning in a regular expression or to use one of the Perl category shortcuts like \w or \s), you must use two in the double-qouted string that represents the regular expression:
_findre("http://www.regex.com/pattern/matching.html#intro", "/(\\w+)/") == < < 20, 29 >, < 21, 28 > >
If you know Perl and are used to putting qualifiers after a regular expression (e.g. "/i", "/s", or "/m"), note that there is a syntax for adding those qualifiers inside a regular expression. (This is part of the standard Perl regular expression syntax.) They can even be altered in the middle of the regular expression, having them affect just part of the regular expression:
_findre("this string\nhas a newline", "string.has", 0) == FALSE _findre("this string\nhas a newline", "(?s)string.has", 0) == < < 5, 15 > > _findre("aBcD AbcD", "Ab(?i)cd") == < < 5, 9 > >