Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Regular expression help

by graff (Chancellor)
on Aug 17, 2005 at 21:21 UTC ( #484608=note: print w/replies, xml ) Need Help??


in reply to Regular expression help

Yes. You can look up the "qr//" operator in perlre, (update: better yet, look it up in perlop), or you can simply assign a regex string to a variable, and use that variable in matches:
#!/usr/bin/perl use strict; my $testdata = 'This is a foo bar test'; while ( my $testregex = <DATA> ) { chomp $testregex; my $result = ( $testdata =~ /$testregex/ ) ? "matched" : "did not +match"; print "Test data $result $testregex\n"; } __DATA__ foo o{1,2} \w{5,10} \w{1,5} \d bar

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2021-01-26 00:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?