hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 18c3d7e05bb3ca4ce759450264116d671fcaf396
parent 943729b4f523013d973d4e8c2a8a4847ca8fb23e
Author: Vlad-Stefan Harbuz <vlad@vladh.net>
Date:   Fri, 13 May 2022 16:41:18 +0100

regex: add some printing to README example to make usage clearer

Signed-off-by: Vlad-Stefan Harbuz <vlad@vladh.net>

Diffstat:
Mregex/README | 8++++++++
1 file changed, 8 insertions(+), 0 deletions(-)

diff --git a/regex/README b/regex/README @@ -26,6 +26,9 @@ the longest match among the leftmost matches. defer free(groups); // The match groups provide the content, start index and end // index of the main match, as well as all submatches. + fmt::printfln("{} ({}, {})", groups[0].content, + groups[0].start, + groups[0].end)!; }; const all_matches = regex::findall(&re, "Hello Hare, hello Hare.")!; @@ -35,6 +38,11 @@ the longest match among the leftmost matches. defer regex::freeall(groupsets); // A slice of multiple match group sets, which can be used // similarly to the find() example. + for (let i = 0z; i < len(groupsets); i += 1) { + fmt::printfln("{} ({}, {})", groupsets[i][0].content, + groupsets[i][0].start, + groupsets[i][0].end)!; + }; }; [0]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_04