Christer Ekholm wrote: > Steve Bertrand <st...@ibctech.ca> writes: > >> Umar Draz wrote: >>> Hello Steve >>> >>> Thanks for your help. >>> >>> Would you please help me one thing more >>> >>> I have string e.g >>> >>> $str = "Hello this is my string (1020p0404), this string is not complete >>> (1 034 400 3). now the string complte"; >>> >>> I want to remove spaces form within ( ) not whole string. Please help me >>> how I can do that. >> Undoubtedly, there are far better ways to do this, but this is what I >> came up with quickly: >> >> > > I found a way using /e and join+split, probably not better. But more fun :) > > $str =~ s/\(([^)]+?)\)/(join('',split(' ',$1)))/ge;
Ohhh spiffy! That's a lot more compact than what I came up with! my @parts = $str =~ /^(.*?)(\(.*?\))(.*?)(\(.*?\))(.*)$/g; $parts[3] =~ s/\s+//g; $str = join('', @parts); Steve
smime.p7s
Description: S/MIME Cryptographic Signature