Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: How do I extract named variable names from regex string

by JavaFan (Canon)
on Jan 31, 2012 at 02:33 UTC ( #950857=note: print w/replies, xml ) Need Help??


in reply to Re^2: How do I extract named variable names from regex string
in thread How do I extract named variable names from regex string

Thank you for playing, but you fail.

"" =~ /(?:(?<mon>\w+)\s(?<mon>\w+))?/; say scalar keys %-; # 1
All that's required is for the pattern to match. Taking the pattern, and wrapping it inside a (?: )? will make it match against "" (except for some degenerate cases). If you look back at my code, this is exactly what I did.

Replies are listed 'Best First'.
Re^4: How do I extract named variable names from regex string
by LanX (Chancellor) on Jan 31, 2012 at 03:47 UTC
    Ups ... you're right!

    Cheers Rolf

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://950857]
help
Chatterbox?
[LanX]: hm just read an article on heise.de claiming that RPerl is 250 times faster. ... it's that even possible?
[marto]: under certain circumstances perhaps
[RonW]: as I understand it, RPerl "compiles" a subset of Perl to C, so I would expect the final executable to run a lot faster

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (11)
As of 2017-05-22 20:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?