in reply to Fix whitespace around symbols
What code have you already written?
Personally, I would extract the "special" symbols and their surrounding whitespace from the first sentence and then replace the elements accordingly in the second sentence:
my %symbols = ( '/' => [], '*' => [], '-' => [], ); $_= "This is a perl script/program."; push @{ $symbols{ '/' }}, m!(\s*[/]\s*)!; push @{ $symbols{ '*' }}, m!(\s*[*]\s*)!; push @{ $symbols{ '-' }}, m!(\s*[-]\s*)!; my $target= "C'est un perl script / programme"; $target =~ s!\s*([/*-])\s*!shift $symbols{ $1 }!ge;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Fix whitespace around symbols
by corfuitl (Sexton) on Mar 20, 2015 at 14:49 UTC | |
by Corion (Patriarch) on Mar 20, 2015 at 15:00 UTC | |
by corfuitl (Sexton) on Mar 23, 2015 at 08:34 UTC | |
by Corion (Patriarch) on Mar 23, 2015 at 08:45 UTC | |
by corfuitl (Sexton) on Mar 23, 2015 at 15:34 UTC |
In Section
Seekers of Perl Wisdom