Batch file 批处理-获取第一个和最后一个双引号之间的字符串

Batch file 批处理-获取第一个和最后一个双引号之间的字符串,batch-file,Batch File,我有这样一个字符串: Testing:"abc"def"ghi" 我想得到:abc“def”ghi并将其放入变量中,是否有任何可能的方法 我需要一种通用的方法(第一个和最后一个引号,而不是第一个和第四个引号)只要字符串不包含未加引号的特殊字符,例如&您的意思是:echo new=%result%??很好用,非常感谢@ngubk-是的,我有两个工作版本,并且设法发布了一个介于两者之间的版本。全部修复:)@jeb-我知道你明白这是怎么回事,但我明白你的意思。这个答案确实值得一个解释-完成:-) @

我有这样一个字符串:

Testing:"abc"def"ghi"
我想得到:
abc“def”ghi
并将其放入变量中,是否有任何可能的方法


我需要一种通用的方法(第一个和最后一个引号,而不是第一个和第四个引号)

只要字符串不包含未加引号的特殊字符,例如
&
您的意思是:echo new=%result%??很好用,非常感谢@ngubk-是的,我有两个工作版本,并且设法发布了一个介于两者之间的版本。全部修复:)@jeb-我知道你明白这是怎么回事,但我明白你的意思。这个答案确实值得一个解释-完成:-)
@echo off
set str=Testing:"abc"def"ghi"extra
echo str = %str%
set "new=%str:*"=%
echo new = %new%
str = Testing:"abc"def"ghi"extra
new = abc"def"ghi
Environment variable substitution has been enhanced as follows:

    %PATH:str1=str2%

would expand the PATH environment variable, substituting each occurrence
of "str1" in the expanded result with "str2".  "str2" can be the empty
string to effectively delete all occurrences of "str1" from the expanded
output.  "str1" can begin with an asterisk, in which case it will match
everything from the beginning of the expanded output to the first
occurrence of the remaining portion of str1.
set "var=value" this text after the last quote is ignored
set "var=This entire sentence is included in the value.