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

Re: Can I test if a parameter expansion has worked



2022-09-15 08:34:34 +0100, zzapper:
[...]
> if [[ $f =~ '.jpg|gif|png|jpeg' ]] ;then echo 'ok' ;else echo 'nok' ;fi
[...]

ITYM

if [[ $f =~ '\.(jpe?g|gif|png)$' ]]

Or (better as regexps can often not be used with non-text while
zsh globs can):

if [[ $f = *.(jp(e|)g|gif|png) ]]

-- 
Stephane




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