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

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



Unless I'm missing something, this looks like a bug:

~$ a='1_2_3_4_5_6'
~$ echo ${a#(*_)(#c1)}
2_3_4_5_6 #OK
~$ echo ${a#(*_)(#c2)}
2_3_4_5_6
~$ echo ${a#(*_)(#c3)}
3_4_5_6
~$ echo ${a#(*_)(#c4)}
4_5_6
~$ echo ${a#(*_)(#c5)}
4_5_6
~$ echo ${a#(*_)(#c6)}
3_4_5_6
~$ echo ${a#(*_)(#c7)}
4_5_6

~$ echo ${a%(_*)(#c1)}
1_2_3_4_5
~$ echo ${a%(_*)(#c2)}
1_2_3_4_5_6
~$ echo ${a%(_*)(#c3)}
1_2_3_4_5_6
~$ echo ${a%(_*)(#c4)}
1_2_3_4

~$ echo ${(S)a/(*_)(#c1)/+}
+2_3_4_5_6
~$ echo ${(S)a/(*_)(#c2)/+}
+2_3_4_5_6
~$ echo ${(S)a/(*_)(#c3)/+}
+3_4_5_6

These are OK:

~$ echo ${a#(?_)(#c1)}
2_3_4_5_6
~$ echo ${a#(?_)(#c2)}
3_4_5_6
~$ echo ${a#(?_)(#c3)}
4_5_6

~$ echo ${a#([^_]#_)(#c1)}
2_3_4_5_6
~$ echo ${a#([^_]#_)(#c2)}
3_4_5_6
~$ echo ${a#([^_]#_)(#c3)}
4_5_6


zsh 5.0.2 (x86_64-pc-linux-gnu) and zsh 5.1.1 (x86_64-debian-linux-gnu)

-- 
Stephane



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