Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^4: Regular expression help: why does this not match?

by Hofmator (Curate)
on Jan 19, 2007 at 08:01 UTC ( #595417=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Regular expression help: why does this not match?
in thread Regular expression help: why does this not match?

Bugfix:

my $valid_re = qr/^(?:$valid)$/;
Without the grouping there will be strange things happening ;-). Apart from that, depending on the situation, you might want to replace $ at the end of the regex with \z depending on whether you want to allow newlines behind the valid items (your solution) or not (\z).

Update: To see the strange things happening, try

my @valid = qw/foo bar baz/; my @a_bunch_of_inputs = qw/fooZZZ ZZbarZZ ZZZbaz foobaz foo bar baz/;
and all of the inputs will produce okay.

-- Hofmator

Code written by Hofmator and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.


Comment on Re^4: Regular expression help: why does this not match?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2014-07-23 05:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (133 votes), past polls