From fd43568cc54e17c8b4a845677872c6282bc6dbb7 Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Wed, 15 Dec 2021 19:47:02 +0100 Subject: d: Merge upstream dmd 93108bb9e, druntime 6364e010, phobos 575b67a9b. D front-end changes: - Import dmd v2.098.1-beta.1. - Default extern(C++) compatibility to C++17. Druntime changes: - Import druntime v2.098.1-beta.1. - Fix definition of stat_t on MIPS64 (PR103604) Phobos changes: - Import phobos v2.098.1-beta.1. gcc/d/ChangeLog: * d-lang.cc (d_init_options): Set default -fextern-std= to C++17. * dmd/MERGE: Merge upstream dmd 93108bb9e. * gdc.texi (Runtime Options): Document the default for -fextern-std=. libphobos/ChangeLog: PR d/103604 * configure: Regenerate. * configure.ac (libtool_VERSION): Update to 3:0:0. * libdruntime/MERGE: Merge upstream druntime 6364e010. * src/MERGE: Merge upstream phobos 575b67a9b. * testsuite/libphobos.traits/all_satisfy.d: New test. * testsuite/libphobos.traits/traits.exp: New test. --- libphobos/src/std/regex/package.d | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'libphobos/src/std/regex') diff --git a/libphobos/src/std/regex/package.d b/libphobos/src/std/regex/package.d index 82207b6..8db0b1e 100644 --- a/libphobos/src/std/regex/package.d +++ b/libphobos/src/std/regex/package.d @@ -70,7 +70,7 @@ $(TR $(TD Objects) $(TD ... // multi-pattern regex - auto multi = regex([`\d+,\d+`,`(a-z]+):(\d+)`]); + auto multi = regex([`\d+,\d+`, `([a-z]+):(\d+)`]); auto m = "abc:43 12,34".matchAll(multi); assert(m.front.whichPattern == 2); assert(m.front[1] == "abc"); @@ -80,9 +80,17 @@ $(TR $(TD Objects) $(TD assert(m.front[1] == "12"); ... - // The result of the `matchAll/matchFirst` is directly testable with if/assert/while. - // e.g. test if a string consists of letters: - assert(matchFirst("Letter", `^\p{L}+$`)); + // The result of `matchAll/matchFirst` is directly testable with `if/assert/while`, + // e.g. test if a string consists of letters only: + assert(matchFirst("LettersOnly", `^\p{L}+$`)); + + // And we can take advantage of the ability to define a variable in the $(LINK2 https://dlang.org/spec/statement.html#IfCondition `IfCondition`): + if (const auto captures = matchFirst("At l34st one digit, but maybe more...", `((\d)(\d*))`)) + { + assert(captures[2] == "3"); + assert(captures[3] == "4"); + assert(captures[1] == "34"); + } --- $(SECTION Syntax and general information) -- cgit v1.1