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&ampquot;, (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