Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Issue with ${var#(*_)(#cN,M)}



2015-10-19 12:17:28 -0700, Bart Schaefer:
> On Oct 19, 10:33am, Stephane Chazelas wrote:
> } Subject: Issue with ${var#(*_)(#cN,M)}
> }
> } Unless I'm missing something, this looks like a bug:
> 
> Hm.  I think it's counting the number of times it backtracked.  E.g.
> 
> } ~$ a='1_2_3_4_5_6'
> } ~$ echo ${a#(*_)(#c2)}
> } 2_3_4_5_6
> 
> Here, it first matched "1_2_3_4_5_" but then couldn't match a second
> time, so it backtracked, matched "1_", and stopped counting.
[...]

Note that the:

~$ echo ${a#*_*_}
3_4_5_6
~$ echo ${a#*_*_*_}
4_5_6

work OK.

And also:

~$ echo ${a#(*_)(*_)(*_|)}
3_4_5_6
~$ echo ${a#(*_)(*_)(*_|)4}
_5_6

(equivalent of (#c2,3))

-- 
Stephane



Messages sorted by: Reverse Date, Date, Thread, Author