Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have minor improvements to jeb's clever "always" solution. Currently jeb's solution has the following issues:</p> <ol> <li>If the leading path is enclosed in quotes, then the first output starts with ""</li> <li>If the trailing path is enclosed in quotes, then the last output ends with ""</li> <li>If any path contains harmless but non-functional consecutive "", then the output preserves the ""</li> <li>If var contains consecutive ;; delimiters then outputs <strong>ECHO is off</strong></li> </ol> <p>This solution fixes the minor issues, plus it uses 2 fewer substitutions. Also I eliminated the unnecessary repeated enabling/disabling delayed expansion within the loop. <em>(Edit on 2011-10-30 simplified the ENDLOCAL logic)</em></p> <pre><code>@echo off setlocal DisableDelayedExpansion set "var=%var:"=""%" set "var=%var:^=^^%" set "var=%var:&amp;=^&amp;%" set "var=%var:|=^|%" set "var=%var:&lt;=^&lt;%" set "var=%var:&gt;=^&gt;%" set "var=%var:;=^;^;%" set var=%var:""="% set "var=%var:"=""Q%" set "var=%var:;;="S"S%" set "var=%var:^;^;=;%" set "var=%var:""="%" setlocal EnableDelayedExpansion set "var=!var:"Q=!" for %%a in ("!var:"S"S=";"!") do ( if "!!"=="" endlocal if %%a neq "" echo %%~a ) </code></pre> <p>If you want to see a blank line for each empty path resulting from consecutive ;; delimiters, then the last line of the FOR loop can simply read <code>echo(%%~a</code> instead.</p> <p>Or perhaps it would be more obvious to display empty paths as "" using:<br> <code>if %%a=="" (echo "") else echo %%~a</code></p> <p>The various empty path fixes work for jeb's simple solution as well.</p> <p><br/></p> <h2>UPDATE: Here is a simple one-liner using JREPL.BAT</h2> <p>You can use my <a href="http://www.dostips.com/forum/viewtopic.php?f=3&amp;t=6044" rel="nofollow">JREPL.BAT regular expression text processing utility</a> to achieve a simple, very robust solution. JREPL.BAT is pure script (hybrid JScript/batch) that runs natively on any Windows machine from XP onward.</p> <pre><code>jrepl "([^;\q]+|\q.*?(\q|$))+" $0 /x /jmatch /s path </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.
 

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