benchrifa has asked for the wisdom of the Perl Monks concerning the following question:
Hello everybody,
This is my code:
#!/usr/bin/perl my $string = "P5§2\nAAA\nBBB\nCCC\nP6§21\n"; $string =~ s/^(P\d+[^\n]*?\n) (([^\n]+) (\n))+ (?:P\d+[^\n]*?)$ /$1$2/xsmig;# print "\$string is \n$string \n";
I got this output:
P5º2 CCC
And I would like to get this one:
P5º2 AAABBBCCC
Thank you for your help
Benchrifa
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Unable to replace targeted newlines in a string
by moritz (Cardinal) on Oct 30, 2009 at 11:20 UTC | |
by benchrifa (Novice) on Oct 30, 2009 at 13:32 UTC | |
|
Re: Unable to replace targeted newlines in a string
by Marshall (Canon) on Oct 31, 2009 at 11:47 UTC |