Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

RegExp Help Needed

by morbus (Sexton)
on Oct 25, 2000 at 15:03 UTC ( #38320=perlquestion: print w/replies, xml ) Need Help??
morbus has asked for the wisdom of the Perl Monks concerning the following question:

What I need to do is turn every like instance of the following:
and I said "damn!", (that "smarts!").
into:
and I said "damn", that "smarts!".
In essence, to turn every non paren'd quote into the HTML equivalent. I can get this working if I do a regexp to change paren'd quotes to %%, and then do another regexp to change every quote in the line to the HTML equiv., and then a final regexp to change %% back to ", but I'm looking for a way to do it in one clean regexp. Any ideas?

Replies are listed 'Best First'.
Re: RegExp Help Needed
by princepawn (Parson) on Oct 25, 2000 at 16:05 UTC
    dchetlin answered you at face value. However, what you want in general sounds like a job for a template module. Why don't you check out Template or Text::Template and see if they can help you out.

    Or the general summary of such tools in this Template Module Review

RE: RegExp Help Needed
by dchetlin (Friar) on Oct 25, 2000 at 15:49 UTC
    It depends on how robust you need to be. If you don't care about things like `(that "smarts (especially like this)!")', you could do:

    s/"(?![^(]*\))/"/g

    If you really need to have it balance correctly with escaped or quoted parens, you'll probably want to look at a module (I've heard good things about Text::Balanced and I suspect it could help here, but having never worked with it I'll defer to others).

    -dlc

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://38320]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2018-07-20 05:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (424 votes). Check out past polls.

    Notices?