Comment #0 by Jesse.K.Phillips+D — 2012-03-08T14:10:44Z
When using std.regex.replace the format parameter is also requiring to be a valid regex. The below example is expected to pass
import std.regex;
void main() {
auto str = "hello?";
assert(str.replace(regex(r"\?", "g"), r"\?") == r"hello\?");
}
This should fail:
import std.regex;
void main() {
auto str = "hello?";
assert(str.replace(regex(r"\?", "g"), r"\\?") != r"hello\?");
}
Maybe I'm wrong on this, but the current requirement seems off.
Comment #1 by dmitry.olsh — 2012-03-09T03:30:45Z
(In reply to comment #0)
> When using std.regex.replace the format parameter is also requiring to be a
> valid regex.
Strange.
But speaking of format string it is expected to be a plain string there is no need to escape a thing in there IRC.
The below example is expected to pass
>
> import std.regex;
>
> void main() {
> auto str = "hello?";
>
> assert(str.replace(regex(r"\?", "g"), r"\?") == r"hello\?");
> }
>
> This should fail:
>
> import std.regex;
>
> void main() {
> auto str = "hello?";
>
> assert(str.replace(regex(r"\?", "g"), r"\\?") != r"hello\?");
> }
>
> Maybe I'm wrong on this, but the current requirement seems off.
Apparently it is, I'll take a look.
Comment #2 by github-bugzilla — 2012-03-17T11:04:23Z