I have some substring [ aa bb cc ] in a line, like $line = "1 2 a b [ aa bb cc ] c d [ bb cc ] 3 4". And I want to trim all the spaces in these substrings. The following code does not work.
while($line =~ /\[(.*?)\]g/)
{
$1 =~ s/\s+//g;
}
Can someone help please
s{\[(.*?)\]}{
my $s = $1;
$s =~ s/\s+//g;
$s
}eg;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With