title: Trim specific chars, but only if they are at the start or end of the variable
body: <p>Say I have a variable set like this:</p>
  <pre><code>basePath=&quot;/some/path/&quot;
  </code></pre>
  <p>I need to trim this such that it will result as <code>&quot;some/path&quot;</code>.</p>
  <p>But I need it to result as <code>&quot;some/path&quot;</code> if it is set like any of these:</p>
  <pre><code>basePath=&quot;/some/path&quot;
  
  basePath=&quot;some/path/&quot;
  
  basePath=&quot;some/path&quot;
  </code></pre>
  <p>In C# this is a fairly easy task.  It has a built in trim function that can take care of this for me.</p>
  <p>In Bash I am seeing examples that assume you know if the leading and trailing chars are there.  I am trying to sanitize some input, so I don't really know if the leading or trailing slashes are there.</p>
  <p><strong>How can I trim off the leading and trailing forward slashes if they are there, but not trim any other chars?</strong></p>