ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> ruby-talk
ruby-talk
Re: Doing an AND in regexp char class
by David A. Black other posts by this author
May 8 2008 6:04PM messages near this date
Re: Doing an AND in regexp char class | 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!
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

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved