On 25-Sep-2015 22:37, skilion wrote:
On Friday, 25 September 2015 at 07:40:18 UTC, Dmitry Olshansky wrote:
Removing anonymous groups and using raw-literal:

regex(`^\s*(\w+)\s*=\s*"(.*)"\s*$`)

Looks simpler I guess.

Good advice, thanks.

Though if key="value" is expected I'd suggest to use lazy .* -
`"(.*?)"` to stop on first " if any.

After playing a bit with it, I realized that it doesn't work in this
case (a="a"a" still match). The right solution would be "(.[^"])"

I hope that was ([^"]*)

Yeah, .*? won't work because of '$' at the end of the pattern.
Anyway to allow classical escapes in string literal I'd go for:

`"(?:[^"]+|\")*"`

--
Dmitry Olshansky
  • Re: OneDrive Client written in... Dmitry Olshansky via Digitalmars-d-announce

Reply via email to