title: XSLT regular expression to accept only few characters in a string
body: <p>I am writing a regular expression which will allow only below special characters:</p>
  
  <pre><code>- _ * &amp; . , #
  </code></pre>
  
  <p>I wrote below function which will avoid all the characters except mentioned in below pattern:</p>
  
  <pre><code>&lt;xsl:function name="wd:allowed_characters"&gt;
      &lt;xsl:param name="input_param" /&gt;
      &lt;xsl:if test="$input_param !=' '" &gt;
          &lt;xsl:value-of select="normalize-space(replace($input_param,'[^.#, \- _ * a-zA-Z0-9]',''))" /&gt;
      &lt;/xsl:if&gt;
  &lt;/xsl:function&gt;
  </code></pre>
  
  <p>My problem is whenever I try to add <code>&amp;</code> in the pattern at any place, I got below errors:</p>
  
  <blockquote>
    <p>Severity: fatal<br>
    Description: The entity name must immediately follow the '&amp;' in the entity </p>
    
    <p>Severity: error<br>
    Description: Failed to compile stylesheet. 1 error detected.</p>
  </blockquote>
  
  <p>I want to know about how can I add <code>&amp;</code> in the pattern like other special characters?</p>