Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
MBEGIN, MEND in #m when pattern has "|"
- X-seq: zsh-workers 38582
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: MBEGIN, MEND in #m when pattern has "|"
- Date: Thu, 2 Jun 2016 19:41:33 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to; bh=N68lFIQ+DhkHfruO5DdOsIrsAhFvUdRCoq/mYuhg8p0=; b=vKML1TWs/KqtEl3j1UHtvbsZNdkr22MJ8UsowXg7Q6joywhhBof4yJCAMIigpqf/Zz 5KE8sXP4SBbZH+rThjUzEu1Y6HKrcmTTv0FTphZfGZ+8Em32BbSTc4jpFHs5dBGxOzoV /JWChyecRZJ2KgO5cZTd9BOJqLHQh63X51Jbj2QvCGRweMo5duVQ1Qde4mU5WgFhwRc6 QUF0NUmS0JofeEfGdYWrMIs1HU6gbgqHzybLSPNNVXymf3nlAK47qc5LV62huzw3l3Px TyAhF+DwVmJ7B0Gp8MKjg+ErrWMDCSCm52AYvHcXnWt1WxAOlFkIqtqMH2YQ6Jzm1hx1 bU+A==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
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[@]}"
Messages sorted by:
Reverse Date,
Date,
Thread,
Author