in reply to Merging in perl
This will identify bracketed expressions in sentence 2 and bracket them in sentence 1.
(update: removed unnecessary if)use strict; use warnings; my $snt1 = 'this.is.example.text'; my $snt2 = '[this.is.] [example.text]'; foreach ($snt2 =~ /\[(.+?)\]/g) { $snt1 =~ s/\Q$_\E/[$_]/; } print $snt1;
|
|---|