$test='test "ROYALE JEWELLER"@omr12.test.com test'; $test=~s!"(.*) (.*)"!"$1$2"!; # print $test
>> test "ROYALEJEWELLER"@omr12.test.com test If you want to remove all the whitespaces that may be between "" $test='test "ROYALE JE WEL LER "@omr12.test.com test'; 1 while $test=~s!"(.*) (.*)"!"$1$2"!g; print $test >> test "ROYALEJEWELLER"@omr12.test.com test bour9 -----Message d'origine----- De : [email protected] [mailto:[email protected]] De la part de Brian Raven Envoyé : mardi 1 juin 2010 12:31 À : [email protected] Objet : RE: Replace white space between "" Serguei Trouchelle <> wrote: > Stephane Legault wrote: > >> I need to replace white space between delemiter "". After looking for >> do this I need to tell I did not find the solution! >> $test='test "ROYALE JEWELLER"@omr12.test.com <mailto:"ROYALE >> JEWELLER"@omr12.networksolutionsemail.com> test'; And I would like >> have this in $test3 (look the space between royale and jeweller is >> gone): test "ROYALEJEWELLER"@omr12.networksolutionsemail.com test > > $test =~ s/(".*?")/ $_ = $1; s!\s!!g; $_; /gex; A possible alternative for matching the quoted substring is to use Regexp::Common. It may be more verbose, but it has the advantage of handling embedded quotes, as long as they are escaped. For example: -------------------------------------------- use strict; use warnings; use Regexp::Common; while (<DATA>) { chomp; print "Before: '$_'\n"; s/$RE{quoted}{-keep}/$_ = $1; s!\s!!g; $_/egx; print "After: '$_'\n"; } __DATA__ test "ROYALE JEWELLER"@omr12.test.com test test "ROYALE \"JELLY\""@omr12.test.com test -------------------------------------------- See 'perldoc Regexp::Common' for more useful REs. The code is quite interesting too. -- Brian Raven _______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs _______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
