title: How can I remove all leading and trailing punctuation?
body: <p>I want to remove all the leading and trailing punctuation in a string. How can I do this?</p>
  
  <p>Basically, I want to preserve punctuation in between words, and I need to remove all leading and trailing punctuation.</p>
  
  <ol>
  <li><code>.</code>, <code>@</code>, <code>_</code>, <code>&amp;</code>, <code>/</code>, <code>-</code> are allowed if surrounded by letters
  or digits</li>
  <li><code>\'</code> is allowed if preceded by a letter or digit</li>
  </ol>
  
  <p>I tried </p>
  
  <pre><code>Pattern p = Pattern.compile("(^\\p{Punct})|(\\p{Punct}$)");
  Matcher m = p.matcher(term);
  boolean a = m.find();
  if(a)
      term=term.replaceAll("(^\\p{Punct})", "");
  </code></pre>
  
  <p>but it didn't work!!</p>