in reply to Remove double bracket and singe quotes
Your test case doesn't have simple [something] in it. If you are willing to delete all of the brackets, not just the double ones, then a shorter more simple, tr statement can be used. Tr is in general faster than a regex with substitution and because its features are so limited, there is no need to escape the characters, so the expression is more readable.
use warnings; use strict; my $doc = q('C-3PO' or 'See-Threepio' is a humanoid robot character fr +om the [[Star Wars]] universe who appears in the original ''Star Wars +'' films, the prequel trilogy and the sequel trilogy.); $doc =~ tr/[]'//d; print "$doc\n"; __END__ C-3PO or See-Threepio is a humanoid robot character from the Star Wars + universe who appears in the original Star Wars films, the prequel tr +ilogy and the sequel trilogy.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Remove double bracket and singe quotes
by marioroy (Prior) on May 02, 2016 at 19:23 UTC | |
by Marshall (Canon) on May 02, 2016 at 20:23 UTC | |
by mr_mischief (Monsignor) on May 02, 2016 at 21:49 UTC | |
by bart (Canon) on May 03, 2016 at 11:38 UTC | |
by marioroy (Prior) on May 02, 2016 at 22:30 UTC | |
by SimonPratt (Friar) on May 03, 2016 at 09:54 UTC | |
Re^2: Remove double bracket and singe quotes
by marioroy (Prior) on May 03, 2016 at 02:27 UTC |