Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^3: Incorrect Pattern Matching Behavior

by hv (Prior)
on Mar 22, 2006 at 02:03 UTC ( [id://538378]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Incorrect Pattern Matching Behavior
in thread Incorrect Pattern Matching Behavior

The problem is in the implementation of this clause:

Either INOUT or OUTPUT

Your regular expression is getting parsed as:

/ # either this ^ S \s+ [-]* \d+ [\.\d+]* \s+ [-]* \d+ [\.\d+]* \s* \( \s* IOPUT | # or this OUTPUT \s* \) /ix

To achieve your aims, you need to tell perl where your list of alternates starts and ends, with capturing (...) or non-capturing (?:...) parens:

/ # all of this ^ S \s+ [-]* \d+ [\.\d+]* \s+ [-]* \d+ [\.\d+]* \s* \( \s* # and one of these two (?: IOPUT | OUTPUT ) # and all of this \s* \) /ix

I'd also recommend using the extended layout permitted by the //x flag for long expressions like this.

Hope this helps,

Hugo

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-19 15:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found