How to remove the hard brackets from a variable in a windows batch script?
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
.
精彩评论