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

Re: Why approximate pattern doesn't match?



On May 9, 10:11pm, Sebastian Gniazdowski wrote:
} Subject: Re: Why approximate pattern doesn't match?
}
} Hello again,
} it appears that the approximate matching works only for first word in
} the *~^* sequence:
} 
} a=( "git push" )
} pattern1='git*~^*pash*'

I read that as: git followed by anything, except NOT matching (~)
anything NOT containing "pash".  Who came up with that double-negative?

} Any solution?

It doesn't seem so.

	/*
	 * By default, approximations are turned off in exclusions:
	 * we need to do this here as otherwise the code compiling
	 * the exclusion doesn't know if the flags have really
	 * changed if the error count gets restored.
	 */

So you don't get approximate non-matching, only approximate matching.

You can possibly refactor it this way:

    a=( "git push" )
    pat1='git*'
    pat2='*pash*'
    echo ${(@M)${(@M)a:#(#ia2)$~pat1}:#(#ia2)$~pat2}



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