From: Todd Benson Date: 2008-05-09T11:09:15+09:00 Subject: Re: Doing an AND in regexp char class On Thu, May 8, 2008 at 7:26 PM, Joel VanderWerf wrote: > Todd Benson wrote: >> >> I'm drawing a blank here with this one. Why doesn't this work then... >> >> irb(main):006:0> r = /\A[oh]*\z/ >> => /\A[oh]*\z/ >> irb(main):007:0> s = "hello, there" >> => "hello, there" >> irb(main):008:0> r === s >> => false > > Maybe I'm confused about was wanted originally. The above tests the > following condition: > > (set of chars occurring in given string) > is_a_subset_of > (given set of chars). Yep. The subject title is misleading, because the AND is already there [^ho] means not h _and_ also not o. I was looking to find if given a string A, can I say whether or not all of the characters in string A exist in string B (count doesn't matter, just existence). All of you gave me some good answers that I hadn't thought of. Good brain food :-) Todd