|Pathologically Eclectic Rubbish Lister|
Simple RegEx Substring Extraction from a Delimited Text Recordby ozboomer (Friar)
|on Mar 15, 2006 at 05:11 UTC||Need Help??|
ozboomer has asked for the wisdom of the Perl Monks concerning the following question:
A simple query, this one, I think... but of interest to those who aren't too flash on regex (like me!)
I have a text record and I would like to extract the 2nd field from it, viz:
Now, the simple but kindof-obscure way to do it might be:
The somewhat better way, although more obscure for people not used to regex might be:
Perhaps there's an even more elegant way to do it using regex?
At any rate, I generally go for the simplest way of doing something, as the PCs we use these days are getting pretty quick (yes, Win32 development again)... but I want to get some more practice with using regex.
I looked in the on-line docs, amongst the monks articles and in the O'Reilly regex and cookbook books but couldn't find something simple... So I thought I'd drop a question in here.
Something else... In terms of maintenance, what is the 'best'(!?) way to go? Assume my maintainer is an expert in regex or go for the "lowest common denominator" (assuming performance isn't critical and simplicity is king)?
Would appreciate any thoughts....