title: Exclude special characters in the start and end of the string
body: <p>I want a regular expression to exclude special characters in the start and end of the string</p>
  
  <p>I tried this code but its not working</p>
  
  <pre><code>String strFileName = Regex.Replace(FileName, @"[^A-Za-z0-9-_ ]", "");
  
  &lt;asp:RegularExpressionValidator ID = "Regular" 
              ValidationGroup = "valGroup" runat="server" ControlToValidate = "txtreport"
              ErrorMessage = "Please enter valid data."
              ValidationExpression = "([a-z]|[A-Z]|[0-9])*"&gt;
  &lt;/asp:RegularExpressionValidator&gt;
  </code></pre>