Reputation: 127
I am trying to replace the \
with \\
in a string variable which contains a network folder path. script is
regsub -all {'\'} $folderpath {\\} $folderpath
if it is other character i am able to replace, since its \
, I am getting problem.
Upvotes: 0
Views: 3917
Reputation: 13252
set folderpath [string map {\\ \\\\} $s]
is about five times faster than using regsub
.
Note that the file
command has several subcommands that can manage a path string regardless of what the separators look like.
Upvotes: 2
Reputation: 16428
% set path {C:\Dinesh\Downloads\Movies\Friends}
C:\Dinesh\Downloads\Movies\Friends
% regsub -all {\\} $path {\\\\}
C:\\Dinesh\\Downloads\\Movies\\Friends
%
Upvotes: 0