How the hell to split multiple delims?

Craig Dillabaugh craig.dillabaugh at gmail.com
Sat Feb 15 22:30:03 UTC 2020


On Saturday, 15 February 2020 at 11:32:42 UTC, AlphaPurned wrote:
> I've tried 10 different ways with split and splitter, I've used 
> all the stuff that people have said online but nothing works. I 
> always get a template mismatch error.
>
> Why is something so easy to do so hard in D?
>
> auto toks = std.regex.split(l, Regex("s"));
> auto toks = std.regex.splitter(l, Regex("s"));
> auto toks = std.regex.splitter(l, ctRegex!r"\.");

I had the same problem myself recently, and almost ended up here 
to ask the same question as you but stumbled across the following 
(ugly) solution without using regexs.

char[] line = "Split this by#space or#sign."

auto parts = line.splitter!(a => a=='#' | a==' ').array;






More information about the Digitalmars-d-learn mailing list