Hey Rick,

On Aug 4, 2006, at 1:48 PM, Rick DeNatale wrote:

> I just ran across this, and can't figure out what's happening.  the
> show_regexp method is as shown on p73 of the Pickaxe 2nd ed.
>
> irb(main):013:0> show_regexp("comparison is", /[:alpha:][^.?!\s'"]*/)
> => "com<<parison>> is"
> irb(main):014:0> show_regexp("comparison is", /[:alpha:][^\s]*/)
> => "com<<parison>> is"
> irb(main):015:0> show_regexp("comparison is", /[:alpha:][\S]*/)
> => "com<<parison>> is"
> irb(main):016:0> show_regexp("comparison is", /[a-zA-Z][\S]*/)
> => "<<comparison>> is"
> irb(main):017:0> show_regexp("comparison is", /[a-zA-Z][^\s]*/)
> => "<<comparison>> is"
>
> It looks like the Posix :alpha: character class doesn't include c,  
> o, or m?!?
>
> Or am I missing something?
>
> -- 
> Rick DeNatale
>


You need another pair of brackets around the :alpha:

So like this:

show_regexp("comparison is", /[[:alpha:]][\S]*/)

That tripped me up when I first used the Posix classes in Ruby, too.

-- Brian