From: "David A. Black" Date: 2008-05-09T10:04:12+09:00 Subject: Re: Doing an AND in regexp char class Hi -- On Fri, 9 May 2008, Joel VanderWerf wrote: > David A. Black wrote: >>> irb(main):013:0> /(?=.*h)(?=.*o)/ === "h o" >>> => true >> >> That depends on the order, though. > > Yes, it's buggy. Should use //m: > > irb(main):003:0> /(?=.*h)(?=.*o)/ === "o \nh" > => false > irb(main):004:0> /(?=.*h)(?=.*o)/m === "o \nh" > => true > > Does that fix the order problem you were thinking of? Actually I think I was wrong about the order mattering (since they're zero-width). But /m helps anyway. I still think you could just change the roles of the two strings and dissect "the string" as a character class and "the characters" as a string, and use your original technique. David -- Rails training from David A. Black and Ruby Power and Light: INTRO TO RAILS June 9-12 Berlin ADVANCING WITH RAILS June 16-19 Berlin INTRO TO RAILS June 24-27 London (Skills Matter) See http://www.rubypal.com for details and updates!