Are you sure you only want these six characters escaped? What about properly escaping the backslash itself?
# escape using quotemeta: say "\Q$dir\E"; # escape only those six characters plus "\\": $dir =~ s/(?=[][{~*?\\])/\\/g; say $dir;
In reply to Re: Faster way to regex this
by Anonymous Monk
in thread Faster way to regex this
by jar00n
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |