From: Todd Benson Date: 2008-05-08T03:59:35+09:00 Subject: Re: Check if char in string? On Wed, May 7, 2008 at 1:40 PM, globalrev wrote: > On 7 Maj, 19:39, m...@tidbits.com (matt neuburg) wrote: > > > globalrev wrote: > > > how do i do this: > > > > > str = "you muppet" > > > > > if "y" in str: > > > print "its in there" > > > > I always use regex in this situation: > > > > if str =~ /y/ > > > > m. > > > > -- > > matt neuburg, phd = m...@tidbits.com,http://www.tidbits.com/matt/ > > > Leopard -http://www.takecontrolbooks.com/leopard-customizing.html > > AppleScript -http://www.amazon.com/gp/product/0596102119 > > Read TidBITS! It's free and smart.http://www.tidbits.com > > > > but none of that is what i want to do. > > i want to chekc if a char is in a string. > not check if a char equals another char. Along with the other suggestions, it might help you to read up on regular expressions and what Ruby considers as true for a condition. 3 == false # false 3 == true # false if 3; puts 'hi'; end # hi if {}; puts 'hi'; end # hi if []; puts 'hi'; end # hi Todd