Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: print identical keys once along with their values

by bsherkhane (Initiate)
on Jan 26, 2016 at 06:38 UTC ( [id://1153638]=note: print w/replies, xml ) Need Help??


in reply to Re: print identical keys once along with their values
in thread print identical keys once along with their values

Thank you very much, can you explain me the regex in details , like what is \2 and $1 $4 $3 special variables purpose regards, Umesh
  • Comment on Re^2: print identical keys once along with their values

Replies are listed 'Best First'.
Re^2: print identical keys once along with their values
by Athanasius (Archbishop) on Jan 26, 2016 at 07:40 UTC

    Hello bsherkhane,

    The escape sequences \1, \2, \3, etc., are backreferences to captures in the current regex. The special variables $1, $2, $3, etc., are likewise backreferences to the captures in the most recent regex. $1 refers to the first capture, $2 to the second capture, and so on. Captures are numbered by counting left parentheses from the left. See perlre#Capture-groups.

    The module YAPE::Regex::Explain is a useful tool for understanding regular expressions. Here is the explanation it gives for the left-hand side (i.e., the regex part) of the substitution in question:

    Hope that helps,

    Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1153638]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-23 18:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found