The rex:
operator defines a function expressed in the
previously described regular expression syntax. The regular
expression proper is preceded and followed by an arbitrary
delimiter character, which may be any printing character
desired.
The resulting function accepts a single string as input and returns at minimum a boolean flag indicating whether or not the string was successfully matched.
Stack: rex: myfn /^ab*c$/ Stack: "abc" myfn Stack: t pop "ad" myfn Stack: nil
If there are any parentheses in the regular expression, the function in addition returns one string value for each parenthesis pair, giving the substring matched by that parenpair.
Stack: rex: myfn /^a(b*)c$/ Stack: "abbbc" myfn Stack: t "bbb" pop pop "ad" myfn Stack: nil ""
Go to the first, previous, next, last section, table of contents.