Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
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.


Comment on Re^3: How do I extract named variable names from regex string
Select or Download Code
Re^4: How do I extract named variable names from regex string
by LanX (Canon) 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?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (10)
As of 2014-12-22 11:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (116 votes), past polls