enhanced index and match
This commit is contained in:
25
qse/regress/awk/lang-038.awk
Normal file
25
qse/regress/awk/lang-038.awk
Normal file
@ -0,0 +1,25 @@
|
||||
#
|
||||
# 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;
|
||||
}
|
||||
}
|
@ -1990,6 +1990,35 @@ pq...r AAA2
|
||||
|
||||
kbs ddd
|
||||
dif cccc
|
||||
--------------------------------------------------------------------------------
|
||||
../../cmd/awk/.libs/qseawk --newline=on -o- -f lang-038.awk </dev/stdin 2>&1
|
||||
--------------------------------------------------------------------------------
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
1 abc
|
||||
7 abc
|
||||
13 abc
|
||||
----------------
|
||||
1 abc
|
||||
7 abc
|
||||
13 abc
|
||||
--------------------------------------------------------------------------------
|
||||
../../cmd/awk/.libs/qseawk -f quicksort.awk quicksort.dat </dev/stdin 2>&1
|
||||
--------------------------------------------------------------------------------
|
||||
|
@ -148,6 +148,7 @@ PROGS="
|
||||
lang-035.awk/lang-035.dat2//--newline=on -o- -vdatafile=lang-035.dat1 -vgroupname=lang-035
|
||||
lang-036.awk/lang-036.dat//--newline=on -o-
|
||||
lang-037.awk/lang-037.dat//--newline=on -o-
|
||||
lang-038.awk///--newline=on -o-
|
||||
|
||||
quicksort.awk/quicksort.dat//
|
||||
quicksort2.awk/quicksort2.dat//
|
||||
|
Reference in New Issue
Block a user