in reply to Re: Simple RegEx Substring Extraction from a Delimited Text Record
in thread Simple RegEx Substring Extraction from a Delimited Text Record
Interestingly, in perl6 I would think it natural to begin with such as:
grammar foo_db { rule key { <[A-Z]> } rule scalar { <[^,]>+ } rule list { [<scalar> ,]+ <scalar> } rule term { <key> = [<list> | <scalar>] } rule record { [<term> <[|]>]* <term> } }
-- to exactly specify the records of the database, rather than either loosely accept the data or make it hard to quickly determine how loosely (or, perhaps, wrongly) the data is taken.
Although I like to do this in perl5, it's not quite so easy to take a verifying regex and make it only accept certain keys, or fail on invalid values. As it isn't so easy or terse or maintainable, split// is preferred, and ultimately very strenuous testing is preferred.
Please don't take that last paragraph as an indictment.
|
|---|