I've found a workaround for testing of -F has been given in one go – via the super cool negation `~`: QE='zparseopts qqq -F afwe' print ${QE//(#b)zparseopts(*~*-F*~*-)(-F|)*/°match°} printf °%s\\n "$match[@]" $? Output: °match° ° qqq °-F °0 So the -F exists there in $match[3] for testing if it has been given to zparseopts. The main point is the ~ rejection of -F on part of the input string: …(*~*-F*~*-)… It translates: everything (*) but not -F (~*-F*) and in that subset, also not dash = (~*-). Without the ~*- it would match "not -F", so "-" from within it is still allowed: QE='zparseopts qqq -F afwe' print ${QE//(#b)zparseopts(*~*-F*)(-F|)*/°match°} printf °%s\\n "$match[@]" $? Output: °match° ° qqq - ° °0 With it and with ~*-F* it correctly accepts other options: QE='zparseopts qqq -q -F afwe' print ${QE//(#b)zparseopts(*~*-F*~*-)(-F|)*/°match°} printf °%s\\n "$match[@]" $? Output: °match° ° qqq -q °-F °0 I think that this demonstrates the uniqueness of Zsh pattern negations. That really should be available in regexps. On Wed, 25 Jan 2023 at 14:52, Sebastian Gniazdowski wrote: > PS. (#b) is missing in the pattern, correct code is: > [[ "zparseopts -F" == (#b)*(zparseopts)*~^*(-F)* ]] > printf →%s\\n $? "$match[@]" > > output is the same. > > > On Wed, 25 Jan 2023 at 14:50, Sebastian Gniazdowski < > sgniazdowski@gmail.com> wrote: > >> Hi, >> I'm matching a pattern: >> [[ "zparseopts -F" == *(zparseopts)*~^*(-F)* ]] >> printf →%s\\n $? "$match[@]" >> >> with output: >> →0 >> →zparseopts >> → >> >> I would want \3 to contain -F… because, I would once want to use (-F|) >> there, and be able to test if the option is given… Is it possible? >> >> ~^ is a double negation that makes the pattern work like "if-contains >> zparseopts AND -F" >> >> >> -- >> Best regards, >> Sebastian Gniazdowski >> >> > > -- > Best regards, > Sebastian Gniazdowski > > -- Best regards, Sebastian Gniazdowski