Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Possible to match string supporting backslash quoting?



HI,
I'm matching var="…" and would want to support quoting, i.e.: var="abc\"ef". So far I have:

qstr='(#B)(["](#b)(*~(*[^\\]([\\][\\])#["]*)))["]'
[[ '"qqq--\\"abc"' == (#b)$~qstr ]];printf ·ec=%s\\n $?;@str-dump match
Output:
·ec=1

qstr='(#B)(["](#b)(*~(*[^\\]([\\][\\])#["]*)))["]'
[[ '"qqq--\"abc"' == (#b)$~qstr ]];printf ·ec=%s\\n $?;@str-dump match

Output:
·ec=0
1: qqq--\"abc
2:
3: 

So it at least detects a \\" in the input. Would it be possible to utilize the negations ~ and ^ to somehow match "str\"ef" as: str"ef, and "str\\"ef" as: str?

--
Best regards,
Sebastian Gniazdowski



Messages sorted by: Reverse Date, Date, Thread, Author