Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>EDIT: This is wrong, see my comment later</strong>: As Joey said, there seems no possibility to use the quote as delim, it can be only used as EOL character.<br> This seems to be an effect of the FOR-LOOP parser of cmd.exe, as it scans the options-part and stops scanning it after an quote, only the EOL= option breaks this, as it read always the next character without any expection. </p> <p>You can solve it with a workaround like icabod.<br> The solution is to replace the quotes with an unused character, but if you want to accept any character inside the quotes there isn't an unused character.</p> <p>So my solution first creates an unused character, by replacing all previous occurences.<br> I want to use the <code>#</code> to replace the quotes, ut to preserve all <code>#</code> inside the quotes a replace it before with <code>$R</code>, but then it can collides with an existing <code>$R</code> in the text, therefore I first replace all <code>$</code> with <code>$D</code>, then it is absolutly collision free.<br> After extracting the "quoted" text, I have to replace the $R and $D back to their original values, that's all.</p> <pre><code>@echo off setlocal EnableDelayedExpansion for /F "tokens=1,2" %%1 in ("%% #") DO ( for /f "tokens=* usebackq" %%a in ("datafile.txt") do ( set "z=%%a" set "z=!z:$=$D!" set "z=!z:#=$R!" set "z=!z:"=#!" for /f "tokens=1-3 delims=#" %%a in ("!z!") do ( set "value=%%b" if defined value ( set "value=!value:$R=#!" set "value=!value:$D=$!" echo result='!value!' ) ) ) ) </code></pre> <p>Sample text:<br> <code>&lt;?define ProductShortName="Two #$* $D $R" ?&gt;</code><br> results to <code>Two #$* $D $R</code> as expected</p> <p><strong>EDIT: There is a way!</strong><br> I always tested things like this (and it fails)</p> <pre><code>setlocal EnableDelayedExpansion set "var=one"two"three" FOR /F ^"tokens^=1-3^ delims^=^"^" %%a in ("!var!") do echo %%a--%%b--%%c </code></pre> <p>But removing the first quote, it works. </p> <pre><code>setlocal EnableDelayedExpansion set "var=one"two"three" FOR /f tokens^=1-3^ delims^=^" %%a in ("!var!") do echo %%a--%%b--%%c </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload