title: perl regex remove quotes from string
body: <p>I would like to remove trailing and leading single quotes from a string, but not if a quote starts in the middle of the string.</p>
  
  <p>Example: I would like to remove the quotes from <code>'text is single quoted'</code> but not from <code>text is 'partly single quoted'</code>.
  Example 2: In <code>abc 'foo bar' another' baz</code>, no quote should be removed because the one on the beginning of the string is missing.</p>
  
  <p>Here my code:</p>
  
  <pre><code>use strict;
  use warnings;
  
  my @names = ("'text is single quoted'", "text is 'partly single quoted'");
  map {$_=~ s/^'|'$//g} @names;
  print $names[0] . "\n" . $names[1] . "\n";
  </code></pre>
  
  <p>The or (<code>|</code>) in the regex <code>^'|'$</code> obviously also removes the second quote from the second string, which is not desired. 
  I thought <code>^''$</code> would mean that it only matches if the first <strong>and</strong> the last character is a single quote, but this won't remove any single quote rom neither string.  </p>