zsh-users
 help / color / mirror / code / Atom feed
* Possible to match string supporting backslash quoting?
@ 2023-01-27 11:47 Sebastian Gniazdowski
  2023-01-27 13:30 ` Stephane Chazelas
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Gniazdowski @ 2023-01-27 11:47 UTC (permalink / raw)
  To: Zsh Users

[-- Attachment #1: Type: text/plain, Size: 624 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 2080 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-01-27 13:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-27 11:47 Possible to match string supporting backslash quoting? Sebastian Gniazdowski
2023-01-27 13:30 ` Stephane Chazelas
2023-01-27 13:35   ` Stephane Chazelas

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).