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

Re: How to repel a space separated quoted strings with ~?



the solution is to pre-split with Z flag then replace spaces with some special char like mom breaking space then join then apply the pattern then replace back 

niedz., 5 cze 2022, 11:12 użytkownik Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx> napisał:
Hi
Consider the following: 

ice="a|b|c|d"
x="a b X c' x' d' e' Z"

if [[ $x =   (#b)(((($~ice)*\ )#)((([^[:space:]]#)~(#B)(($~ice)*))\ ))#((#B)(($~ice)*\ )##)(Z) ]]; then
    pl $match
fi

Output: 
a b X c' x'
a b X c'
a b X c'
a
x'
x'
x'
d' e'
Z

The goal is to match blocks of lower letters specified by ice var possibly followed by a glued quoted strings and block of a capital letter.  The repel negation ~ is successful at preventing matching lower letters at the capital paren however only if not glued by a string.  Is there a way to repel also such strings ?

The output should be: 
...
...
...
c' x' d' e'
Z



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