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

RE: Extended glob patterns in ${...#..} RE: Un-patch: new pattern matching code



> Since a closure can match the empty string, the shortest matched portion
> is nothing.  However, asking for the longest match definitely doesn't work:
>
> zagzig<9> print ${(SM)foo##*}
> ab12xy
> zagzig<10> print ${(SM)foo##([[:digit:]])#}
>
> zagzig<11>
>


Believe it or not, it does work today. I have no idea, what went wrong yesterday
(I thought, it was the problem of flag order ...):

bor@itsrm2:~%> foo=ab12xy
bor@itsrm2:~%> print ${(SM)foo##[[:digit:]]#}
12
bor@itsrm2:~%> print ${(MS)foo##[[:digit:]]#}
12

But still, this one is probably unexpected:

bor@itsrm2:~%> print ${(MSI:1:)foo##[[:digit:]]#}
12
bor@itsrm2:~%> print ${(MSI:2:)foo##[[:digit:]]#}
2
bor@itsrm2:~%> print ${(MSI:3:)foo##[[:digit:]]#}

The first is O.K. ... and the third is O.K., but the second? I believe, this is
a clear bug. The ``S'' flag must consider only non-overlapped matches (the same
way, sed works).

/andrej



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