Reputation: 91
HI i am very new to DOS batch shell scripting, i would like to know how to do string replacement, i had str1 with / i need to replace / with _(underscore) but not at front
set str1=/a/b/c/d
set str2=%str1:/=_%
returns me _a_b_c_d but i need a_b_c_d
Thanks, Sanat.
Upvotes: 0
Views: 717
Reputation: 56228
to remove the first character from a string, use:
set str3=%str2:~1%
In fact, you don't have to use different variables. The following lines work fine:
set str=/a/b/c/d
set str=%str:/=_%
set str=%str:~1%
Upvotes: 3