title: Javascript regular expression: remove first and last slash
body: <p>I have these strings in javascript:</p>
  
  <pre><code>/banking/bonifici/italia
  /banking/bonifici/italia/
  </code></pre>
  
  <p>and I would like to remove the first and last slash if it's exists.</p>
  
  <p>I tried <code>^\/(.+)\/?$</code> but it doesn't work.</p>
  
  <p>Reading some post in stackoverflow I found that php has trim function and I could use his javascript translation (<a href="http://phpjs.org/functions/trim" rel="noreferrer">http://phpjs.org/functions/trim</a>:566) but I would prefer a "simple" regular expression.</p>