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?
Thanks in Advance,
Richard
BTW, I running Ruby 1.8.6 over WindowsXP-Pro.SP3
========= Test =========
puts "\n1."
pat = /(.+[aiu])(.+[aiu])(.+[aiu])(.+[aiu])/i
str = "Fujiyama"
m = pat.match(str)
(0..5).to_a.each { |i| puts "m[%d]: %s" % [i, m[i].to_s] }
puts "\n2."
pat = /noun/i
str = "The 'noun' word is here"
m = pat.match(str)
(0..5).to_a.each { |i| puts "m[%d] %s" % [i, m[i].to_s] }
--
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.