leading " character..., so it is currently not of much (any) use, as it is then identically to a "default"
use of that characters, without the need to escape the delimiters.
Maybe another has an idea how to make real use of this;
I've added the working (but on different modes) values [1, 4], Ed's [2] and Jebs/Livius [3]
workarounds, which both works if not beeing used as an variable replacement argument in
delayed expansion. The for loop arguments 5 to 7 shows the default behavior within a
string [5], outside a string [6], and the escaped version [7].
It has also a modified version of Livius code for a testing the resulting strings:
Code: Select all
@echo off
cls
setlocal enableDelayedExpansion
set LF=^
@rem "=^"
set ^"v1=^"=^^^""
@rem a<lf>b
set ^"v2=a!LF!b"
for %%v in (
"=^^"
a^^^!LF^^^!b
^^^!"^!""=^^^^""^!"^^^!
"a!LF!b"
!"":" a , ; =^^^^"!""!
!" :" a , ; =^^^^"!" !
!" :"^ ^ a^ ^,^;^=^^^^^"!"!
) do (
set "test="
echo testing: %%v
if !v1:%%v+! == !v1:%v1%+! set "test=1" & echo(success: v == "=^"
if !v1:%%~v+! == !v1:%v1%+! set "test=1" & echo(success: ~v == "=^"
if "!v2:%%v=+!" == "+" set "test=1" & echo(success: v == a^!LF^!b
if "!v2:%%~v=+!" == "+" set "test=1" & echo(success: ~v == a^!LF^!b
if not defined test echo(failed
echo(
)
endlocal
goto :eof
penpen