title: Parsing output of wsl --list --verbose in JavaScript
body: <p>Aim: Offer docker-desktop feature of showing status of wsl (stopped/running). In Docker Desktop this can be seen in the left bottom corner.</p>
  <p>Consequence: Parse output of wsl --list --verbose</p>
  <p>Current implementation in main.ts of electron app:</p>
  <pre class="lang-js prettyprint-override"><code>ipcMain.on('cmd', async (event, arg)=&gt;{
    const execute = (command, callback)=&gt;{
      exec(command, (error, stdout, stderr) =&gt; {
        callback(stdout);
      });
    };
  
  // call the function
    execute('wsl --list --verbose', (output) =&gt; {
      event.sender.send('cmd-callback',output)
    });
  })
  </code></pre>
  <p>Problem: <a href="https://i.stack.imgur.com/9FP9r.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9FP9r.png" alt="Image of output in regexr.com" /></a></p>
  <p>Current attempt:  <code>console.log(args.split(/[\r\n|\n|\r]/).filter(String))</code></p>
  <p>Current result:</p>
  <pre><code>[
      &quot; \u0000 \u0000N\u0000A\u0000M\u0000E\u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000S\u0000T\u0000A\u0000T\u0000E\u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000V\u0000E\u0000R\u0000S\u0000I\u0000O\u0000N\u0000&quot;,
      &quot;\u0000&quot;,
      &quot;\u0000*\u0000 \u0000U\u0000b\u0000u\u0000n\u0000t\u0000u\u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000S\u0000t\u0000o\u0000p\u0000p\u0000e\u0000d\u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u00002\u0000&quot;,
      &quot;\u0000&quot;,
      &quot;\u0000 \u0000 \u0000d\u0000o\u0000c\u0000k\u0000e\u0000r\u0000-\u0000d\u0000e\u0000s\u0000k\u0000t\u0000o\u0000p\u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000S\u0000t\u0000o\u0000p\u0000p\u0000e\u0000d\u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u00002\u0000&quot;,
      &quot;\u0000&quot;,
      &quot;\u0000 \u0000 \u0000d\u0000o\u0000c\u0000k\u0000e\u0000r\u0000-\u0000d\u0000e\u0000s\u0000k\u0000t\u0000o\u0000p\u0000-\u0000d\u0000a\u0000t\u0000a\u0000 \u0000 \u0000 \u0000 \u0000S\u0000t\u0000o\u0000p\u0000p\u0000e\u0000d\u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u00002\u0000&quot;,
      &quot;\u0000&quot;,
      &quot;\u0000&quot;
  ]
  </code></pre>
  <p>Required output as a JavaScript Array [string[]]:</p>
  <pre><code>[
    ['Ubuntu', 'Stopped', '2'],
    ['docker-desktop', 'Stopped', '2'],
    ['docker-desktop-data', 'Stopped', '2'],
  ]
  </code></pre>