Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
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 ;-)

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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://7634]
help
Chatterbox?
[Corion]: Lady_Aleena: Mostly, it's just housekeeping, but it inspires me about things I could do with it, so that's good ;)
[Lady_Aleena]: By the way, I stopped by to let someone know I'm still alive, though I haven't found anything to write in perl for a while now.
[Lady_Aleena]: I need inspiration.
[Discipulus]: hello there: Lady_Aleena for inspiration random browse my homenode.. ;=)
[Lady_Aleena]: Discipulus, Hello there. How are you?

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2017-09-24 18:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (274 votes). Check out past polls.

    Notices?