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