Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Regular expression help

by philcrow (Priest)
on Aug 17, 2005 at 21:29 UTC ( [id://484610]=note: print w/replies, xml ) Need Help??


in reply to Regular expression help

You can use regex quoting to build up expressions from pieces. It looks something like this:
my $name = qr/\w{1,100}/; my $num = qr/\d{1,100}/; $input =~ m{ employee \( ($name) ,\s* ($name) ,\s* ($num) \) }x; my ($first_name, $last_name, $number) = ($1, $2, $3);
So you can store regexes in vars usin the qr quoting operator, then use them in subsequent regexes merely by mentioning them. They will interpolate.
Phil

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2024-04-18 15:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found