Skip to content

Commit

Permalink
std.regex: Fix math in replace example
Browse files Browse the repository at this point in the history
Not only was the sum of two numbers incorrect, but the replace
operation seemingly added 100 to the result as well ;)
  • Loading branch information
CyberShadow committed Apr 18, 2012
1 parent 071aa17 commit f25f1f7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion std/regex.d
Expand Up @@ -6557,7 +6557,7 @@ public auto bmatch(R, RegEx)(R input, RegEx re)
---
//Comify a number
auto com = regex(r"(?<=\d)(?=(\d\d\d)+\b)","g");
assert(replace("12000 + 42100 = 56000", com, ",") == "12,000 + 42,100 = 56,100");
assert(replace("12000 + 42100 = 54100", com, ",") == "12,000 + 42,100 = 54,100");
---
The format string can reference parts of match using the following notation.
Expand Down

0 comments on commit f25f1f7

Please sign in to comment.