Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: parsing file/regex question

by tadman (Prior)
on Oct 23, 2003 at 20:40 UTC ( [id://301709]=note: print w/replies, xml ) Need Help??


in reply to parsing file/regex question

Are those \n characters supposed to be newlines?

Try this:
while (<DATA>) { s/\\n/\n/g; print "yep\n" if /$PRE($VALID1+)$PST/; }
Two yeps.

Replies are listed 'Best First'.
Bit more help on this? Re: Re: parsing file/regex question
by smackdab (Pilgrim) on Oct 23, 2003 at 21:31 UTC
    Thanks, that does make sense, but does "break" the data driven approach I am trying to come up with...I have expanded the example and maybe someone will come up with a different idea...if not I'll do it the way suggested ;-)
    $PRE = '\[\s*('; $VALID1 = '[-a-zA-Z0-9_.* \t\n]'; $VALID2 = '[-a-z0-9_.*\n]'; $VALID3 = '[a-zA-Z]'; $VALID4 = '[-a-zA-Z0-9]'; $PST = ')\s*\]'; while (<DATA>) { s/\\n/\n/g; #Are these harmless if s/\\t/\t/g; #not needed??? print "yep\n" if m/$PRE($VALID1+)$PST\s* $PRE($VALID2+)$PST\s* $PRE($VALID3+)$PST\s* $PRE($VALID4+)$PST\s* /x; } __DATA__ [TEST \n DATA] [ TEST DATA ] [ 2345423 ] [ TEST\tDATA ]\n [TEST \n DATA] [ TEST DATA ] [ 2345423 ] [ TEST DATA ]\n [TEST \n DATA] [ TEST DATA ] [ 2345423 ] [ TEST\tDATA ]\n

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://301709]
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: (3)
As of 2024-04-25 17:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found