pos returns 0 for an
unsuccessful match, or the starting position for a successful match.
The end position of the match can be retrieved with the
position method.
text = "It's the year 2016!"
re = .RegularExpression~new("[1-9][0-9]*")
begin = re~pos(text)
if begin > 0 then
do
year = text~substr(begin, re~position - begin + 1)
say "Found the number" year "in this sentence."
end
::requires rxregexp.cls
Found the number 2016 in this sentence.