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

how to search for a substring in a parameter?



I'm trying to see if the value of a parameter contains a given string
but didn't find an elegant way. All pattern matching substitutions
return only the non-matched portion of the value. There's a way to do
substitutions but not testing. I must be missing something. I'm using

   if (( ${#foo//pattern/} < ${#foo} )); then
	# contains pattern
   else
	# doesn't contain pattern
   fi

Is there a better way?



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