in reply to Remove blank space during find/replace
As others have put - it is hard to tell where the spaces are coming from without more code. However, your replacement hash looks fine, so you probably have a sneaky space in your replacement code along the lines of (but a '#' instead of ' '):
my $string = '<TList.Bullet><TList.Item>sometext</TList.Item></TList.B +ullet>'; print "Before : \'$string\'\n"; my %find_replace = ( q[<TList.Bullet>] => q[<ul>], q[</TList.Bullet>] => q[</ul>], q[<TList.Item>] => q[<li>], q[</TList.Item>] => q[</li>], ); for (keys %find_replace){ $string =~ s/\Q$_\E/\#$find_replace{$_}/; } print "After : \'$string\'\n"; ## Gives : # Before : '<TList.Bullet><TList.Item>sometext</TList.Item></TList.Bul +let>' # After : '#<ul>#<li>sometext#</li>#</ul>'
But it woul help to see the replacement code and come real input / output.
Update : Forgot to include output... Now included with code.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Remove blank space during find/replace
by Melk (Initiate) on Nov 27, 2009 at 15:45 UTC | |
by cdarke (Prior) on Nov 27, 2009 at 16:51 UTC |