From eea7ef5405ba5280d8d54219551e414183334db1 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Wed, 9 Nov 2016 14:12:42 +0000 Subject: [PATCH] updated documentation on match() --- qse/doc/page/awk-lang.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/qse/doc/page/awk-lang.md b/qse/doc/page/awk-lang.md index e0ef6e53..bdd7bbde 100644 --- a/qse/doc/page/awk-lang.md +++ b/qse/doc/page/awk-lang.md @@ -650,6 +650,20 @@ where the search begins. A negative value indicates a position from the back. } ~~~~~ +match() accepts the fourth parameter. The parameter is set to the array +containing submatches. The caller can get the number of submatches by +dividing the array size by 2. Assuming the array name of x, the nth +submatch is set in x[n,"start"] and x[n,"length"]. + +~~~~~{.awk} + match($0, /^([[:digit:]]+),([[:digit:]]+),([[:digit:]]+)/, 1, xx) >= 1 { + count = length(xx) \ 2; + for (i = 1; i <= count; i++) print xx[i,"start"], xx[i,"length"]; + print RSTART, RLENGTH + } + +~~~~~ + Opeartors ---------------