diff options
author | Iain Buclaw <ibuclaw@gdcproject.org> | 2021-12-15 19:47:02 +0100 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gdcproject.org> | 2021-12-15 19:51:30 +0100 |
commit | fd43568cc54e17c8b4a845677872c6282bc6dbb7 (patch) | |
tree | 24f591392a2978706aef4d58e377b8b42b5ba418 /libphobos/src/std/regex | |
parent | 639ece7abfa3688008cb791aec4c7a1a4f76e59f (diff) | |
download | gcc-fd43568cc54e17c8b4a845677872c6282bc6dbb7.zip gcc-fd43568cc54e17c8b4a845677872c6282bc6dbb7.tar.gz gcc-fd43568cc54e17c8b4a845677872c6282bc6dbb7.tar.bz2 |
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.
Diffstat (limited to 'libphobos/src/std/regex')
-rw-r--r-- | libphobos/src/std/regex/package.d | 16 |
1 files changed, 12 insertions, 4 deletions
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) |