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

regex(String,ZZ,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 = "aa b c aaaa";
i2 : m = regex("a+",0,s)

o2 = {(0, 2)}

o2 : List
i3 : n = regex("a+",4,s)

o3 = {(7, 4)}

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

o4 = aa
i5 : substring(n#0,s)

o5 = aaaa

See also