#!/usr/bin/env perl use strict; use warnings; my $re = qr{\bd"(\w+)}; while () { 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' #### ... 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'