title: How can I represent epsilon in a regular expression?
body: <p>The text book teaches us to write regular expressions using the epsilon <code>(ε)</code> symbol, but how can I translate that symbol directly to code without having to completely rework my regular expression?</p>
  
  <p>For instance, how would I write this regex which would catch all lowercase strings that either begin or end in <code>a</code> (or both).</p>
  
  <p>Not 100% sure this is correct but...</p>
  
  <p>((a|<code>epsilon</code>)[a-z]<code>*</code>a) | (a[a-z]<code>*</code>(a|<code>epsilon</code>))</p>
  
  <p>So some strings that should match include:</p>
  
  <pre><code>a //single "a" starts or ends with "a"
  
  aa //starts and ends with "a"
  
  ab //starts with "a"
  
  ba //ends with "a"
  
  aba //starts and ends with "a"
  
  aaaaaaaa //starts and ends with "a"
  
  abbbbbbb //starts with "a"
  
  bbbbbbba //ends with "a"
  
  abbbbbba //starts and ends with "a"
  
  asdfhgdu //starts with "a"
  
  onoineca //ends with "a"
  
  ahnrtyna //starts and ends with "a"
  </code></pre>
  
  <p>I only what to exchange <code>epsilon</code> for the correct symbol, I do not want to modify any part of the rest of the expression.  Also I want to be clear, I am not actually checking for the epsilon symbol, I want to have a choice of a character or nothing (well not nothing... epsilon).</p>
  
  <p><strong>Does such a symbol exist?</strong></p>
  
  <p><strong>Is what I want possible?</strong></p>