Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Regular expression help

by philcrow (Priest)
on Aug 17, 2005 at 21:29 UTC ( #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
Node Status?
node history
Node Type: note [id://484610]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2021-01-25 23:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?