On Thu, Sep 05, 2002 at 03:04:30PM +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
>
> So, a short and sweet snippet that figures this out, please? The result
> may be whatever form you like.
A first straightforward tentative:
#!perl -l
for( split m[(-)], shift )
{
$i++ and next if /^-$/;
s/./$&-?/g;s/-\?$//;
$ARGV[0] =~/$_/;
print ++$i for 1 ..$& =~y/-//;
}
[yanick@gilgamesh yanick]$ perl hyphen hypo-allergeen hy-po-al-ler-geen
1
3
4
Joy,
`/anick
PS: as a bonus, we can play 'Where's /-\ndrew' with the script.
--
My fear is greater than my faith but I walk the missionary way.
- Suede, Tori Amos