How to divide by space keeping words with spaces inside quotes?

Basile.B b2.temp at gmx.com
Mon Aug 9 04:23:54 UTC 2021


On Monday, 9 August 2021 at 04:19:05 UTC, Basile.B wrote:
> On Sunday, 8 August 2021 at 23:04:32 UTC, Marcone wrote:
>> How to divide by space keeping words with spaces inside quotes?
>>
>> Exanple:
>>
>> string text = "Duck Cat \"Carl Rivers\" Dog";
>>
>> I want split to:
>>
>> ["Duck", "Cat", "Carl Rivers", "Dog"]
>>
>>
>> ATENTION: I DON'T WANT:
>>
>> ["Duck", "Cat", "Carl", "Rivers", "Dog"]
>>
>>
>> How can I get it in Dlang?
>
> You can use a regex. Apparently [the 
> pattern](https://regex101.com/r/cyx0pC/1) `(\"[\w ]*\")|\w*` 
> would work

with `+` as quantifier actually `(\"[\w ]+\")|\w+`


More information about the Digitalmars-d-learn mailing list