zsh-workers
 help / color / mirror / code / Atom feed
* MBEGIN, MEND in #m when pattern has "|"
@ 2016-06-02 17:41 Sebastian Gniazdowski
  2016-06-02 22:11 ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Sebastian Gniazdowski @ 2016-06-02 17:41 UTC (permalink / raw)
  To: Zsh hackers list

Hello,
below is a code that uses indexes set by (#m) or (#b). Turns out the
indexes are set only when using (#b). For (#m) they are set when there
is no "|" in the pattern. Why?

Output is:
==========================

Text is: vim ~/.zshrc s, searching for: vim|s
|-1 0 fg=red,bold|
 ~/.z|-1 0 fg=red,bold|
hrc |-1 0 fg=red,bold|

Text is: vim ~/.zshrc s, searching for: vim|s
|0 3 fg=red,bold|
|8 9 fg=red,bold|
|13 14 fg=red,bold|

Code:
==========================

#!/usr/bin/env zsh

nl=$'\n'
text="vim ~/.zshrc s"
colsearch_pattern="vim|s"

harray=( "${(f)${text//(#mi)${~colsearch_pattern}/|$(( MBEGIN - 1 ))
$(( MEND )) fg=red,bold|$nl}%$nl*}" )
echo "Text is: $text, searching for: $colsearch_pattern"
print -rl -- "${harray[@]}"

print

harray=( "${(f)${(S)text//*(#bi)(${~colsearch_pattern})/|$(( mbegin[1]
- 1 )) $(( mend[1] )) fg=red,bold|$nl}%$nl*}" )
echo "Text is: $text, searching for: $colsearch_pattern"
print -rl -- "${harray[@]}"


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

end of thread, other threads:[~2016-06-04  6:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-02 17:41 MBEGIN, MEND in #m when pattern has "|" Sebastian Gniazdowski
2016-06-02 22:11 ` Bart Schaefer
2016-06-03  4:47   ` Sebastian Gniazdowski
2016-06-04  5:58     ` Bart Schaefer
2016-06-04  6:41       ` 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).