diff options
| author | Tyge Lovset <[email protected]> | 2022-09-06 19:30:51 +0200 |
|---|---|---|
| committer | Tyge Lovset <[email protected]> | 2022-09-06 19:30:51 +0200 |
| commit | a65d94a54ba98ca1fa743d6c70a9b243afad47da (patch) | |
| tree | 16839d8497eaf9f3cab4e5eb7c0efd3db507d35a /docs/cregex_api.md | |
| parent | 90311ff7eb34e5fc4fc1c2c38b8d0433642e9659 (diff) | |
| download | STC-modified-a65d94a54ba98ca1fa743d6c70a9b243afad47da.tar.gz STC-modified-a65d94a54ba98ca1fa743d6c70a9b243afad47da.zip | |
Updated docs for cregex and csview.
Diffstat (limited to 'docs/cregex_api.md')
| -rw-r--r-- | docs/cregex_api.md | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/docs/cregex_api.md b/docs/cregex_api.md index 43ad1f41..87e25e02 100644 --- a/docs/cregex_api.md +++ b/docs/cregex_api.md @@ -130,19 +130,15 @@ In order to use a callback function in the replace call, see `examples/regex_rep To iterate multiple matches in an input string, you may use: ```c csview match[5] = {0}; -while (cregex_find(input, &re, match, cre_m_next) == cre_success) { - c_forrange (int, i, cregex_captures(&re)) - printf("submatch %d: %.*s\n", i, c_ARGsv(match[i])); - puts(""); -} +while (cregex_find(input, &re, match, cre_m_next) == cre_success) + c_forrange (int, k, cregex_captures(&re)) + printf("submatch %d: %.*s\n", k, c_ARGsv(match[k])); ``` -There is also a safe macro that simplifies it a bit: +There is also a safe macro which simplifies this: ```c -c_foreach_match (m, &re, input) { - c_forrange (int, i, cregex_captures(&re)) - printf("submatch %d: %.*s\n", i, c_ARGsv(m.ref[i])); - puts(""); -} +c_foreach_match (it, &re, input) + c_forrange (int, k, cregex_captures(&re)) + printf("submatch %d: %.*s\n", k, c_ARGsv(it.match[k])); ``` ## Using cregex in a project |
