In routing.rb, what is the purpose of the following piece of code: class Regexp #:nodoc: def number_of_captures Regexp.new("|#{source}").match('''').captures.length end Does this method not always return 0? It''s always going to match '''' with the blank spot before the | and therefore will have no captures. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
>> Regexp.new("|(.)").match("a").captures.length=> 1 On 5/21/07, RailsToPerl <rwc006@aim.com> wrote:> > In routing.rb, what is the purpose of the following piece of code: > > class Regexp #:nodoc: > def number_of_captures > Regexp.new("|#{source}").match('''').captures.length > end > > > Does this method not always return 0? It''s always going to match '''' > with the blank spot before the | and therefore will have no captures. > > > > >-- Kevin Clark http://glu.ttono.us --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Just responding to see KC''s response since Google Groups is borked and not showing the last response in each thread. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---