Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Issue with ${var#(*_)(#cN,M)}
2015-10-27 10:46:33 +0000, Peter Stephenson:
[...]
> % egrep '^(*_){2}$' <<<'1_2_'
>
> fails to match completely, i.e the backtracking is too complicated
> to handle, whereas
[...]
Except that it should be .* in REs and that REs are greedy.
$ egrep '^(.*_){2}$' <<<'1_2_'
1_2_
$ grep -Eo '^(.*_){2}' <<<'1_2_3_4_5'
1_2_3_4_
$ grep -Po '^(.*?_){2}' <<<'1_2_3_4_5'
1_2_
ksh93 is also fine with it:
$ a='1_2_3_4_5' ksh -c 'echo "${a#{2}(*_)}"'
3_4_5
$ a='1_2_3_4_5' ksh -c 'echo "${a##{2}(*_)}"'
5
The zsh limitation should probably be documented if not fixed.
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author