in reply to Remove double bracket and singe quotes

This works for me:
#!/usr/bin/perl use 5.010; use strict; use warnings; my $doc = "'C-3PO' or 'See-Threepio' is a humanoid robot character fro +m the [[Star Wars]] universe who appears in the original ''Star Wars' +' films, the prequel trilogy and the sequel trilogy."; $doc =~ s/[\[\]']+//g; say $doc;
Did you mean that you want to only remove one single quote and not two of them?

Replies are listed 'Best First'.
Re^2: Remove double bracket and singe quotes
by smknjoe (Beadle) on May 04, 2016 at 18:38 UTC
    I like how the OP hasn't come back to clarify his problem and qualify what "Doesn't work at all" really means.

    But, I think the answer to your question is "yes"; only a single quote and not double quotes. Which then begs the question (from me) HOW DO YOU do this? As soon as you put a single quote followed by the "g" option on the search-and-replace, it removes all of them.
      $doc =~ s/(?<!\')\'(?!\')//g;

      The above seems to work for OP's example. Only matches single "'" by using negative look-behind and negative look-ahead assertions to avoid matches of more than one consecutive single quote.

        Excellent! I've never had a need to use look-ahead/look-behind in any of my scripts, so this is new territory for me.