Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

(tye)Re: Delete unmatched quotes from a delimited file?

by tye (Sage)
on Jul 25, 2001 at 01:30 UTC ( #99497=note: print w/replies, xml ) Need Help??


in reply to Delete unmatched quotes from a delimited file?

You can rely on some properties of regular expression matching to make this much simpler than what I've seen so far (unless I'm missing something, of course).

s#"([^|"]*)([|"]|$)# ( $2 eq '"' ? '"' : ' ' ) . $1 . $2 #ge;
Look for a " followed by whatever until you hit " or | or end of line. If you hit ", then you found a matched pair so leave the " in. If you don't, then replace the " with a space. The "g" modifier on the regex then starts where the last match left off. This means you don't need to worry about starting a match at the second " of a matched pair.

        - tye (but my friends call me "Tye")

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (1)
As of 2022-01-25 23:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (69 votes). Check out past polls.

    Notices?