G'day nmdahl,

Welcome to the Monastery.

Here's a fairly straightforward way of doing that with a variety of test cases. Note this won't remove the 'd"' from the end of your first posted sentence (1st test case).

#!/usr/bin/env perl use strict; use warnings; my $re = qr{\bd"(\w+)}; while (<DATA>) { s/$re/$1/g; print; } __DATA__ ... and am having trouble with strings containing d". ... if the input string is d"alice I need ... No d + " + alice here. Here's many: d"alice and d"alice and d"alice and ... d"alice at start of line and at end of line: d"alice "d"alice" 'd"alice'

Output:

... and am having trouble with strings containing d". ... if the input string is alice I need ... No d + " + alice here. Here's many: alice and alice and alice and ... alice at start of line and at end of line: alice "alice" 'alice'

If that doesn't do what you want, please post representative input and expected output. The guidelines in "How do I post a question effectively?" explain the best way to do that.

— Ken


In reply to Re: Regex Remove String with Quotations by kcott
in thread Regex Remove String with Quotations by nmdahl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.