summaryrefslogtreecommitdiffhomepage
path: root/misc/examples/regex_replace.c
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-12-30 19:26:51 +0100
committerGitHub <[email protected]>2022-12-30 19:26:51 +0100
commit9d59845f622fbb9c225bbe32246a3128ad9ec0b1 (patch)
tree528ebcc735cdb5d958b987c886d369bc02a11320 /misc/examples/regex_replace.c
parent5f57d597cd27aef55adbcb3b452973b0c6e33667 (diff)
parente124d8c7377de1dfce45790a196312596f6b9be5 (diff)
downloadSTC-modified-9d59845f622fbb9c225bbe32246a3128ad9ec0b1.tar.gz
STC-modified-9d59845f622fbb9c225bbe32246a3128ad9ec0b1.zip
Merge pull request #41 from tylov/allcaps
Allcaps
Diffstat (limited to 'misc/examples/regex_replace.c')
-rw-r--r--misc/examples/regex_replace.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/misc/examples/regex_replace.c b/misc/examples/regex_replace.c
index e296dfd8..a170856b 100644
--- a/misc/examples/regex_replace.c
+++ b/misc/examples/regex_replace.c
@@ -17,7 +17,7 @@ int main()
const char* pattern = "\\b(\\d\\d\\d\\d)-(1[0-2]|0[1-9])-(3[01]|[12][0-9]|0[1-9])\\b";
const char* input = "start date: 2015-12-31, end date: 2022-02-28";
- c_auto (cstr, str)
+ c_AUTO (cstr, str)
{
printf("INPUT: %s\n", input);
@@ -26,17 +26,17 @@ int main()
printf("fixed: %s\n", cstr_str(&str));
/* US date format, and add 10 years to dates: */
- cstr_take(&str, cregex_replace_pattern_n(pattern, input, "$1/$3/$2", 0, add_10_years, CREG_DEFAULT));
+ cstr_take(&str, cregex_replace_pattern_ex(pattern, input, "$1/$3/$2", 0, add_10_years, CREG_DEFAULT));
printf("us+10: %s\n", cstr_str(&str));
/* Wrap first date inside []: */
- cstr_take(&str, cregex_replace_pattern_n(pattern, input, "[$0]", 1, NULL, CREG_DEFAULT));
+ cstr_take(&str, cregex_replace_pattern_ex(pattern, input, "[$0]", 1, NULL, CREG_DEFAULT));
printf("brack: %s\n", cstr_str(&str));
/* Shows how to compile RE separately */
- c_with (cregex re = cregex_from(pattern, CREG_DEFAULT), cregex_drop(&re)) {
+ c_WITH (cregex re = cregex_from(pattern, CREG_DEFAULT), cregex_drop(&re)) {
if (cregex_captures(&re) == 0)
- continue; /* break c_with */
+ continue; /* break c_WITH */
/* European date format. */
cstr_take(&str, cregex_replace(&re, input, "$3.$2.$1"));
printf("euros: %s\n", cstr_str(&str));