On Sun, Feb 28, 2010 at 12:16 PM, RichardOnRails
<[email protected]> wrote:
> Hi,
>
> Below are two tests of using MatchData. The first is essentially Hal
> Futon's taken from The Ruby Way, 2nd. ed. [Thanks, Hal].  In
> particular, m[0] returns the string being searched.
>
> The 2nd is my humble use. For mine, m[0] returns the search pattern,
> it seems,
>
> I can't anything in the code to account for this difference.  I'm
> expecting the first kind of response in a Rails app I'm working on,
> but I'm getting the second kind of response.
>
> Any ideas?

m[0] doesn't return the string being searched, it returns everything
which the entire pattern matched.

In the first case /(.+[aiu])(.+[aiu])(.+[aiu])(.+[aiu])/i entirely
matches "Fujiyama"

in the second case /noun/i only matches a portion of the string, so
that's what is the value of m[0]




-- 
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to