Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Match to the end of string when using (S) flag
- X-seq: zsh-users 22060
- From: Sebastian Gniazdowski <psprint@xxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Match to the end of string when using (S) flag
- Date: Tue, 01 Nov 2016 07:25:33 -0700
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.com; h= content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to:x-me-sender:x-me-sender:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=nhI3g2aQ9s2HtWkSiQygwIY5Z/k=; b=gdqEgL LfihjVOh4f20xqbMUdYru9pXUp5zUOnCg5JvWNlMhouop45QY/OzoxtE0xMIgYZL cL7rCkv7yM++v1bBTMLXpS9VpjG2fYaHno2Y41fF7sak6C8vg3NZiDOBIRiq3fNE eavq3qj11AsaJtXPaqGbTUDGTPQ4P3REeOFaY=
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=smtpout; bh=nhI3g2aQ9s2HtW kSiQygwIY5Z/k=; b=mV4nVAvRjB/1FciGk7jN3I1Bxc8rhBRTOVrgWNtuOjKeah rgBZkxyL5bS25RsLt9Zs6PxXOZhBUkgrC5PS+rXXDvKtYoSQJKBKjtHTJIMzJu8s PNWs5a3/rBkx7wSjo5Q7cFMf9SGTMvFzU9LMgtEawCWN2Bgprsyi6Sq8z0+ZE=
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
Hello,
I do:
% a="AXbcAXdeAXfg"; echo ${(S)a//*(AX)/x}
xxxfg
to generate region_highlight entries. As it can be seen, there is
trailing data, which Zsh converts to "-1 -1 none". I would want to
generate clean region_highlight entries. Came up with this:
% a="AXbcAXdeAXfg"; echo ${a//(*(AX)*(#e)~*AX*AX*|*AX~*AX*AX*)/x}
xxx
Surprisingly, it is faster (e.g. 170ms vs 780 ms) than (S) flag IF AX is
not a complex pattern like AX|BX. Then it is slow, so I cannot use this.
Also, I'm not sure if it isn't possible that exclusion ~*AX*AX* will
lead to acceptance of X*AX*, but this doesn't seem to occur.
Is there way out of this? Thought about using (R) flag out of the set of
BEMNR "... include in result" flags, but I cannot provoke anything
distinct with them.
PS. The actual region_highlight generating code is:
region_highlight+=( "${(f)${(S)text//*(#bi)(${~colsearch_pattern})/$((
offset + mbegin[1] - 1 )) $(( offset + mend[1] ))
${__hsmw_hl_color}${nl}}%$nl*}" )
offset is length of a preamble (all for $POSTDISPLAY) that is not
colored.
--
Sebastian Gniazdowski
psprint@xxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author