title: How to Write a Regular Expression that allows only letters, numbers and special characters only i the middle never in the end
body: <p>Need some regular expressions help.</p>
  
  <p>So far I have my code working to allow a limited number of special characters.  However, I don't know how to get it to only allow them in the middle and never the end.</p>
  
  <p>Can someone help me figure that part out?</p>
  
  <p>Here is the code I am using in c#:</p>
  
  <pre><code>            Regex uRLToVal= new Regex("^[A-Za-z0-9-_.+!*]*$");
  
              if (!uRLToVal.IsMatch(this.mainURL))
              {
                  results.AddPropertyError("Your Entry can only contain letters, numbers, underscores, periods, plus, exclamation marks and hypens. Special characters should always be inside numbers or letters.  Example: v!v is OK BUT NOT !vv or vv!");
              }
  </code></pre>