Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: quoting characters

by ahunter (Monk)
on Apr 14, 2000 at 19:28 UTC ( #7634=note: print w/replies, xml ) Need Help??

in reply to quoting characters

Think I've got it...
while ($_ = <STDIN>) { chomp; s/^((([^\#\\])|(\\.))*)\#.*$/$1/; print "$_\n"; }
Seems to do the trick, assuming record delimiters in STDIN are correctly set. Basically, the regexp matches anything that isn't a comment or a quote character, *or* anything that's a quote character followed by anything. Because perl is greedy, this matches up to the first unquoted comment character, and we just substitute away anything after that...
I think substituting out the quotes themselves requires another s/// statement, but it's fairly trivial ;-)

Replies are listed 'Best First'.
RE: Re: quoting characters
by Anonymous Monk on Apr 14, 2000 at 23:37 UTC
    That is exactly what I have been trying to come up with for the last week. I remembered seeing someone somewhere write a regex to match a C string and I knew that was what I needed, but I couldn't remember the form. Thanks.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2016-10-20 23:01 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (284 votes). Check out past polls.