in reply to how to write this Regular Expression?

Best shot, given the poorly-posed question...

use strict; # Single quote string, and back-whack the backslashes # to avoid misinterpretation (by readers, if not by perl). my $strInputFileName = 'D:\\direcorty\\file.ext'; # Globally replace backslashes with four backslashes. # Note that these all need backwhacking too, since # regex acts somewhat like a quoted string. $strInputFileName =~ s{\\}{\\\\\\\\}g;

I don't know what you're doing with the escaped quotes though. Also, it's directory, not 'direcorty'.