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

Re^2: validate variable-length lines in one regex?

by uhClem (Scribe)
on Jul 06, 2015 at 20:38 UTC ( [id://1133441]=note: print w/replies, xml ) Need Help??


in reply to Re: validate variable-length lines in one regex?
in thread validate variable-length lines in one regex?

Oho! Now that is slick, in a gruesome way. I like it; just might use that. Bonus for doing exactly what I want in an almost unrelated way. It even seems like that could be the basis of a script that could figure out for itself what the probable pattern for each lousy file is, and just yank any outliers... Let's see how big a mess I can make with THAT!

And just the same, there is still that "D D D D D D" -- a non-indeterminate sequence so you just have to hope you don't run into any lines with seven Ds. I bet there's a way around that (and I know I'll never have more than nine -- in this file...) but that does point back to my original question: Can you make a single regex carefully validate a variable number of fields (and return all matches)? Will perl regex do that, or does it exceed the possibilities?

Anyway, thanks!

  • Comment on Re^2: validate variable-length lines in one regex?

Replies are listed 'Best First'.
Re^3: validate variable-length lines in one regex?
by poj (Abbot) on Jul 06, 2015 at 20:47 UTC

    Another thought - If it's possible to edit the file I would put the mask as the first line, no need to edit the script then. Failing that put something in the filename that chooses the correct mask for you. This would of course mean editing the file for each new mask.

    poj

      Hmmm....   Not sure that I would trust the preparer of such files that much.   Nor would I, personally, want to so much as touch the data.   However, you might have some kind of catalog or configuration-file, external to the script, which provides the necessary information.   (And, if the script could not locate exactly-one appropriate entry, for whatever file that it has been given, it would obligingly die().)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-25 19:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found