B
Berger, Daniel
Hi all,
Ruby 1.8.4
Oniguruma 2.5.6
I'm trying to figure out how to get at named backreferences with
Oniguruma, but I'm having some problems figuring it out. Here's the
interface I would *like* to have:
# pseudo.rb
str =3D "hello world"
reg =3D /^(?<first>\w+?)\s(?<last>\w+)$/
match =3D reg.match(str)
first =3D match[:first]
last =3D match[:last]
But this doesn't work - I mean, the regex works, but the way I'm trying
to get at the backreferences does not. Nor does there appear to be
anything like Python's MatchData#groupdict() method (which returns a
hash).
How do I get at the named backreferences from the MatchData object? Is
there a way?
Thanks,
Dan
This communication is the property of Qwest and may contain confidential =
or
privileged information. Unauthorized use of this communication is =
strictly=20
prohibited and may be unlawful. If you have received this communication =
in error, please immediately notify the sender by reply e-mail and =
destroy=20
all copies of the communication and any attachments.
Ruby 1.8.4
Oniguruma 2.5.6
I'm trying to figure out how to get at named backreferences with
Oniguruma, but I'm having some problems figuring it out. Here's the
interface I would *like* to have:
# pseudo.rb
str =3D "hello world"
reg =3D /^(?<first>\w+?)\s(?<last>\w+)$/
match =3D reg.match(str)
first =3D match[:first]
last =3D match[:last]
But this doesn't work - I mean, the regex works, but the way I'm trying
to get at the backreferences does not. Nor does there appear to be
anything like Python's MatchData#groupdict() method (which returns a
hash).
How do I get at the named backreferences from the MatchData object? Is
there a way?
Thanks,
Dan
This communication is the property of Qwest and may contain confidential =
or
privileged information. Unauthorized use of this communication is =
strictly=20
prohibited and may be unlawful. If you have received this communication =
in error, please immediately notify the sender by reply e-mail and =
destroy=20
all copies of the communication and any attachments.