Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
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?
[Lady_Aleena]: marioroy, it is used in 24 other modules I wrote.
[Lady_Aleena]: GUH! I wrote a script better than I thought! 8)
[marioroy]: Wow. It's cool seeing Github coments "Update Monster.pm, Create Wild_hairs, Create alternate- PurpleOnGreen..., Then a location, Create Aleenia. Amazing, really. Thank you for sharing.
Discipulus when naming is clear and you know how to arrange the data, then coding it is a mere writing work

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2017-05-29 09:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?