in reply to Regex to find repeated patterns
That being said, does this code do what you are looking for?
use strict; use warnings; my $str = "*L*Name1*L*Name2*L**D*Place1*D*Place2*D**L*Name3*L*"; my @names =$str =~ m/\*L\*(\w+)/g; print "@names\n"; $str =~ s/\*L\*$names[0]//; print "Modified string = $str\n";
Output:
Name1 Name2 Name3 Modified string = *L*Name2*L**D*Place1*D*Place2*D**L*Name3*L*
|
|---|