in reply to Back reference in s///g ?
Further there's no need to escape the space in the replacement.
But, ignoring the issue of "non-English" (do you mean a different character set, like Greek or Japanese by any chance?), you're close. Try this:
#!/usr/bin/perl use strict; use warnings; my $in = "foo bar blivitz done"; $in =~ s/\s+/\n/g; # replace spaces with \n print "after first regex: $in \n"; # $in =~ s/[a-zA-Z]\n[a-zA-Z]/$1\ $2/g; $in =~ s/([a-zA-Z])\n([a-zA-Z])/$1 $2/g; # remove newlines, restore s +paces print "after second regex: $in \n"; =head execution: ww@GIG:~/pl_test$ perl 675941.pl after first regex: foo bar blivitz done after second regex: foo bar blivitz done ww@GIG:~/pl_test$ =cut
|
|---|