in reply to Find common prefix from a list of strings
Of course it assumes that chr(033) does not appear in the strings...my $sep = chr(033); my $str = join $sep, @files; if ($str =~ /^([^$sep]*)[^$sep]*($sep\1[^$sep]*)*\z/s) { print "Common substring: '$1'\n"; } else { die "Pattern unexpectedly failed to match?"; }
|
|---|