http://www.perlmonks.org?node_id=436538


in reply to Replacing characters in a line

Just use "word-boundary anchors" in your regex:
/\bD\b/

pelagic