On Thu, 05 Sep 2002 15:04:30 +0200, Bart Lateur wrote:
>The problem is this: given two versions of a word, one without, and one
>with hyphenation, determine which hyphens are soft hyphens (optional
>breakpoints), and which ones are hard hyphens? For example:
>
> hypo-allergeen hy-po-al-ler-geen
My own attempt:
@ARGV = qw(hypo-allergeen hy-po-al-ler-geen);
my($word, $split) = @ARGV;
$split =~ s/-|(\W)/$1 ? "\\$1" : '(-?)'/ge;
$word =~ /^$split$/ or die "No match";
for(my $i = @-; --$i > 0;) {
next if $+[$i] > $-[$i];
substr($word, $-[$i], 0) = '­';
}
print $word;
-->
hy­po-al­ler­geen
--
Bart.