Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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 ;-)


Comment on Re: quoting characters
Download Code
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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://7634]
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: (3)
As of 2014-09-18 04:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (108 votes), past polls