zsh-users
 help / color / mirror / code / Atom feed
* Match to the end of string when using (S) flag
@ 2016-11-01 14:25 Sebastian Gniazdowski
  2016-11-01 16:27 ` Sebastian Gniazdowski
  0 siblings, 1 reply; 10+ messages in thread
From: Sebastian Gniazdowski @ 2016-11-01 14:25 UTC (permalink / raw)
  To: zsh-users

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@fastmail.com


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

end of thread, other threads:[~2018-11-07 17:16 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-01 14:25 Match to the end of string when using (S) flag Sebastian Gniazdowski
2016-11-01 16:27 ` Sebastian Gniazdowski
2016-11-01 18:29   ` Sebastian Gniazdowski
2016-11-01 21:23     ` Bart Schaefer
2016-11-02  6:53       ` Sebastian Gniazdowski
2016-11-02 15:50         ` Bart Schaefer
2016-11-02  9:46       ` Peter Stephenson
2018-11-07 12:30       ` Sebastian Gniazdowski
2018-11-07 15:25         ` Bart Schaefer
2018-11-07 17:16           ` Sebastian Gniazdowski

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).