title: Regular expression or operator
body: <p>I'm trying to write a regular expression to test as string. The string must start or end with an alphanumeric character.</p>
  
  <p>eg.</p>
  
  <pre><code>test - OK
  test$ - OK
  $test - OK
  $ - not OK
  $test$ - not OK
  </code></pre>
  
  <p>I can test the beginning with <code>^\w.*$</code> and the end with <code>^\w.*$</code>.</p>
  
  <p>But I can't seem to combine them into something like <code>^.*\w$ | ^\w.*$</code>.</p>
  
  <p>Does anyone have any ideas or even a better regex for this purpose?</p>