r = ~/zz*/
A few options can follow the closing slash. They are m for multi-line, i for ignoring case, g for finding all matches.
r = ~/zz*/gi
A regular expression can be used as either a function, or a set. To match a regular expression r against a string s, just call r as a function:
r(s)The result is the starting and end indices of the match. If the g option of the regular expression is enabled, the result is an matrix with the indices of all the matches given as rows.
Because a function is also a set, so a regular expression can be used anywhere a set is expected, especially for specifying the domain of a function parameter, argument, or a class attribute. For example, the regular expression /zz*/ can be considered as the set of all strings that contain z's.
A regular expression r has the following attributes
The pattern and options attributes can be accessed and reset, and the match attribute is a function that matches the pattern against the argument string.
oz 2009-12-22