|Keep It Simple, Stupid|
Delete unmatched quotes from a delimited file?by Buckaroo Buddha (Scribe)
|on Jul 24, 2001 at 19:48 UTC||Need Help??|
Buckaroo Buddha has asked for the wisdom of the Perl Monks concerning the following question:
I've got a data set that looks somewhat like this:
It is a very large file and It is being imported daily into an MS-SQL server by a SAS script
unfortunately, in this case SAS can't handle quotes very well. So I must clean the file before SAS gets its ruddy little paws on it.
I had hoped to do a quick and sexy inline thing to the effect of:
sweet ... unfortunately there are too many special characters for an inline to work
then I moved on to
sweet, it works! no problem
but now i've found that unmatched quotes still happen at other places in the data. I must instead come up with a way of saying:
"if you find a | before you find a second quote you must substitute it for a blank space"
now one way would be to:
the two questions i have are:
1) is there a better way to do this? I figure regex's are so powerful that this could probably be done in one line. if I went out and bought that O'reilly book on mastering regular expressions do you think i'd be able to write that one myself?
2) is there a way to match any ODD number of quotes as opposed to just one quote?