hare

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

commit 202446b8fed35ef124c4604e485319bb51cf7748
parent dec2748f77ebb811f05c876ae9e72f1f312bf2c8
Author: Vlad-Stefan Harbuz <vlad@vladh.net>
Date:   Fri,  5 May 2023 22:29:29 +0100

regex: add replace() to README

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

diff --git a/regex/README b/regex/README @@ -19,3 +19,13 @@ returned. This implementation computes matches in linear time. const results = regex::findall(&re, "Let's all love Harriet and Hare"); // -> {{"Harriet", "riet"}, {"Hare", "e"}} defer regex::result_freeall(results); + + const re = regex::compile(`love`)!; + const result = regex::replace(&re, "Let's all love Harriet and Hare", + `celebrate`)!; + // -> "Let's all celebrate Harriet and Hare" + + const re = regex::compile(`[a-z]+-([a-z]+)-[a-z]+`)!; + const result = regex::replace(&re, "cat-dog-mouse; apple-pear-plum", + `\1`)!; + // -> "dog; pear"