next | previous | forward | backward | up | top | index | toc | directory | Macaulay 2 web site

regex(String,String) -- regular expression matching

Synopsis

Description

The value returned is a list of pairs of integers corresponding to the parenthesized subexpressions successfully matched. If no matching substring was found, then null is returned. The first member of each pair is the offset within s of the substring matched, and the second is the length.

i1 : s = "The cat is black.";
i2 : word = ///\b([a-z]+)\b///;
i3 : m = regex(word|" "|word,s)

o3 = {(4, 6), (4, 3), (8, 2)}

o3 : List
i4 : substring(m#0,s)

o4 = cat is
i5 : substring(m#1,s)

o5 = cat
i6 : substring(m#2,s)

o6 = is

See also