title: RegEx - removing preceding & trailing whitespace while matching contents
body: <p>I want to try and construct a RegEx statement that will remove any pre-ceeding or trailing white spaces from a string (but leave any contained within the string untouched) while also matching a chosen format. For instance the string must cannot be any longer than 20 characters, can contain any of the characters from a-zA-Z0-9 as well as underscores and hyphens. But most importantly it must trim or ignore any spaces found at either the start or end of the string so:</p>
  
  <p>Correct:
  "Have a nice day"</p>
  
  <p>Incorrect:
  " Have a nice day to "</p>
  
  <p>I have tried many different ways of doing this but unfortunately so far I have not been able to come up with a formula that does exactly what I want. Could anyone help me with a suitable RegEx? (this is a RegEx in its simplest form and not platform specific).</p>