title: Find/replace: regex with some logic, quotes – from input file to output file, single pass
body: <p>I have a file:  </p>
  
  <p><strong>input.txt</strong>:  </p>
  
  <pre><code>a|400|green|blahblah|big
  b|2500|red|text|small
  a|1400|blue|something|medium
  </code></pre>
  
  <p>and I want to convert it to  </p>
  
  <p><strong>output.txt</strong> (note different quotes):  </p>
  
  <pre><code>color: "green"; size: "big"; price: 400
  color: 'red'; size: 'small'; price: 2500
  color: "blue"; size: "medium"; price: 1400
  </code></pre>
  
  <p>That is, regex to find:  </p>
  
  <pre><code>^[ab]\|(.*?)\|(.*?)\|.*?\|(.*?)$
  </code></pre>
  
  <p>and replace with the following:  </p>
  
  <ul>
  <li><p>if a line starts with <code>a|</code>:  </p>
  
  <p><code>color: "\2"; size: "\3"; price: \1</code></p></li>
  <li><p>if a line starts with <code>b|</code>:  </p>
  
  <p><code>color: '\2'; size: '\3'; price: \1</code></p></li>
  </ul>
  
  <p>How to do this in Unix command-line, or sed, or Cygwin, or Bash, in a single pass? The higher the performance, the better (those files are really huge)</p>