| |
| Posted by Salih Dincer in reply to Caten | PermalinkReply |
|
Salih Dincer
| On Sunday, 20 March 2022 at 09:42:44 UTC, Caten wrote:
> On Sunday, 2 January 2022 at 21:16:55 UTC, Amit wrote:
> On Sunday, 2 January 2022 at 19:26:50 UTC, WebFreak001 wrote:
> [...]
On Sunday, 2 January 2022 at 19:37:38 UTC, JG wrote:
> [...]
Yes! That's what I needed.
I wrapped it in a function like so:
string quote(string s) {
return format("%s", [s])[1 .. $ - 1];
}
unittest {
assert(quote("one \"two\"\nthree four") == `"one \"two\"\nthree four"`);
}
Thanks for your responses ^_^
Hi, I also need a function to "unquote" string, like this:
assert(unquote(`\n`)=="\n");
Is there a way to do that?
void main()
{
import std.array : replace;
auto q = `Hello,\n deneme`;
auto p = "Hello,\n deneme";
assert(q.replace("\\n", "\n") == p);
}
SDB@79
|