in reply to Re: Regexp not capturing in named subrules
in thread Regexp not capturing in named subrules
I guess I was just surprised to find this something that's more possible in Ruby-1.9. I'll still probably end up just translating to a proper parser but it was easy to use the regexp engine to start with. The below snippet is equivalent to my perl but does return the capture.
require 'pp' re = %r{ # Grammar rules go here (?: (?<thing>.+) ){0} # Invoke grammar here \g<thing> } m = re.match( 'text' ) puts m['thing'] # puts "text\n"
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Regexp not capturing in named subrules
by ikegami (Patriarch) on Sep 16, 2009 at 16:57 UTC | |
by tye (Sage) on Sep 16, 2009 at 17:20 UTC | |
by diotalevi (Canon) on Sep 16, 2009 at 17:25 UTC | |
by merlyn (Sage) on Sep 16, 2009 at 18:29 UTC | |
by diotalevi (Canon) on Sep 16, 2009 at 18:36 UTC | |
by Corion (Patriarch) on Sep 16, 2009 at 18:49 UTC | |
|
In Section
Seekers of Perl Wisdom