title: Help with awk to truncate and pad
body: <p>I have a long list of Unicode values that are semi-colon delimited.  Here's an example:</p>
  
  <pre><code>E0027;TAG APOSTROPHE;Cf;0;BN;;;;;N;;;;;
  </code></pre>
  
  <p>All I need is the "E0027;" part.</p>
  
  <p>So I first need to drop everything in the line AFTER the first semicolon, but in some cases the semicolon is after 4 digits, in other cases, (as above) it's after 5.  If it were the same throughout I'd just truncate after a fixed number of chars.  I've found lots of examples for doing various manipulations with awk but no regular expressions that seem to fit this particular case.  Does anyone know what the proper syntax is?  The logic is merely to keep everything BEFORE the first semicolon and to drop everything after it.</p>
  
  <p>Then, for the resulting file, I need to add a leading 0 to the line if the number is only 4 chars.  So for example:</p>
  
  <pre><code>8A9B;
  </code></pre>
  
  <p>Should become:</p>
  
  <pre><code>08A9B;
  </code></pre>
  
  <p>But the 5 digit values (such as the first example) should remain as is...no leading zero.  </p>
  
  <p>(Though would an extra leading zero make a difference if I'm using these values in HTML?  Would it matter if I had:</p>
  
  <pre><code>&amp;#x0E0027
  </code></pre>
  
  <p>Instead of:</p>
  
  <pre><code>&amp;#xE0027
  </code></pre>
  
  <p>If these will be parsed identically by PHP and won't make a difference, I guess the latter part isn't so important (though with thousands of extra zeros it will bloat the size of the code.)</p>
  
  <p>Thank you for any help in advance!</p>