更新时间:2023-11-14 12:28:10
@echo off
setlocal EnableDelayedExpansion
set mystring=Non quoted string
echo %mystring%
if !mystring:~0^,1!!mystring:~-1! equ "" (
echo -^> String is quoted
) else (
echo -^> String not quoted
set newstring="%mystring%"
echo New string: !newstring!
)
echo/
set mystring="My quoted string"
echo %mystring%
if !mystring:~0^,1!!mystring:~-1! equ "" (
echo -^> String is quoted
) else (
echo -^> String not quoted
set newstring="%mystring%"
echo New string: !newstring!
)