From: khaines@... Date: 2007-01-14T13:09:17+09:00 Subject: Re: checking if a string matches a regexp - am I missing something? On Sun, 14 Jan 2007, Rob Sanheim wrote: > I want to know if a string matches a regular expression. I don't care > where the match begins, I don't want a matchdata object, I don't want > to check for nil, I just want a boolean indicating if a string matches > a regexp. And I want this to be one method call. From what I can > tell, this is the closest I can get: > > reg = /\w/ > reg === "string" # close, but I want to send the message to the > string, not the other way around > ("string" =~ reg) >= 0 # ugly > ("string" =~ reg) != 0 # still ugly > "string".include? reg # this would seem to follow the ruby way, but it > throws a TypeError What am I not understanding here? "string" =~ reg Kirk Haines