String "dequote" in phobos?

kdevel kdevel at vogtner.de
Thu May 13 17:13:40 UTC 2021


On Thursday, 13 May 2021 at 16:40:29 UTC, Imperatorn wrote:
> Wouldn't this just this do that? 🤔
>
> ```d
> string dequote(string s)
> {
>     return s[1..$-1];
> }
> ```

1. Your code throws Range errors if s.length < 2.
2. assert(dequote(`"fo\"o"`) == `fo"o`) fails
3. dequote(`"fo"o"`) does not throw.


More information about the Digitalmars-d-learn mailing list