[MacRuby] #1135: regular expression subroutines not supported

MacRuby ruby-noreply at macosforge.org
Fri Jan 28 10:11:54 PST 2011


#1135: regular expression subroutines not supported
-------------------------------------+--------------------------------------
 Reporter:  mattaimonetti@…          |       Owner:  lsansonetti@…        
     Type:  defect                   |      Status:  new                  
 Priority:  minor                    |   Milestone:                       
Component:  MacRuby                  |    Keywords:                       
-------------------------------------+--------------------------------------
 The following example which works in CRuby 1.9.2 doesn't compile in
 MacRuby:

 {{{
 sentence = %r{
     (?<subject>   cat   | dog   | gerbil    ){0}
     (?<verb>      eats  | drinks| generates ){0}
     (?<object>    water | bones | PDFs      ){0}
     (?<adjective> big   | small | smelly    ){0}

     (?<opt_adj>   (\g<adjective>\s)?     ){0}

     The\s\g<opt_adj>\g<subject>\s\g<verb>\s\g<opt_adj>\g<object>
 }x

 md = sentence.match("The cat drinks water")
 puts "The subject is #{md[:subject]} and the verb is #{md[:verb]}"

 md = sentence.match("The big dog eats smelly bones")
 puts "The adjective in the second sentence is #{md[:adjective]}"

 sentence =~ "The gerbil generates big PDFs"
 puts "And the object in the last is #{$~[:object]}"
 }}}

 {{{
 compilation error: U_REGEX_RULE_SYNTAX
 }}}

 More explanation about the subroutines there:

 http://pragdave.blogs.pragprog.com/pragdave/2008/10/fun-with-ruby-19
 -regular-expressions.html

-- 
Ticket URL: <http://www.macruby.org/trac/ticket/1135>
MacRuby <http://macruby.org/>



More information about the macruby-tickets mailing list