开发者

How to remove the hard brackets from a variable in a windows batch script?

开发者 https://www.devze.com 2022-12-17 19:18 出处:网络
I am a windows batch dunce. I have a variable storing some text surrounded by hard brackets like: [glcikLhvxq1BwPBZN0EGMQ==]

I am a windows batch dunce.

I have a variable storing some text surrounded by hard brackets like:

[glcikLhvxq1BwPBZN0EGMQ==]

But I need to p开发者_JAVA技巧ass it as an argument like:

glcikLhvxq1BwPBZN0EGMQ==

How can I strip these hard brackets from the beginning and end in my windows batch file?


You can use the sub-string syntax:

set foo=[glcikLhvxq1BwPBZN0EGMQ==]
set foo2=%foo:~1,-1%

which will remove the first and last characters. The sub-string starts here at the second character (so 1, zero-based) and extends until the second-to-last character (-1).

This is detailed more thoroughly in help set.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号