Re: Doing an AND in regexp char class
by Todd Benson other posts by this author
May 8 2008 7:09PM messages near this date
Re: Doing an AND in regexp char class
|
Re: Doing an AND in regexp char class
On Thu, May 8, 2008 at 7:26 PM, Joel VanderWerf <vjoel@[...].edu> 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
Thread:
Todd Benson
Rick DeNatale
Ara.T.Howard
Pit Capitain
Todd Benson
Joel VanderWerf
7stud --
David A. Black
7stud --
Todd Benson
David A. Black
Joel VanderWerf
Todd Benson
David A. Black
Joel VanderWerf
David A. Black
Ara.T.Howard
Robert Dober
|