title: how to write a regular expression to check a character only could appear once?
body: <p>I really need help. Currently, I have this expression to check the username but I want to add more to check if more than one period or underscore is in the string. If it is, return false. if it is not, return true.</p>
  <pre><code>^([_.a-z0-9]{3,15})$
  </code></pre>
  <p>For example, the following cases will return <em><code>True</code></em>:</p>
  <pre><code>.yhjgh899_
  _.9874juyh
  899j_nnfg
  874083.
  </code></pre>
  <p>The following cases will return <em><code>False</code></em>:</p>
  <pre><code>_jdun_jd.
  jkuf..jf
  </code></pre>