qse/regress/awk/lang-038.awk

26 lines
397 B
Awk
Raw Normal View History

2009-09-17 00:35:29 +00:00
#
# test the third parameter(starting position) of index and match
#
BEGIN {
xstr = "abcdefabcdefabcdef";
xsub = "abc";
xlen = length(xsub);
i = 1;
while ((i = index(xstr, xsub, i)) > 0)
{
print i, substr(xstr, i, xlen);
i += xlen;
}
print "----------------";
i = 1;
while (match(xstr, xsub, i) > 0)
{
print RSTART, substr(xstr, RSTART, RLENGTH);
i = RSTART + RLENGTH;
}
}