in reply to Regex Remove String with Quotations
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
|
|---|