[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[FWP] Regex for the last vowel/diphthong in a word



Okay, I was trying to come up with a regex for the last vowel/diphthong
in a word that is in this set: a, o, u, au.  The best regex I've come
up with so far is this:

/([aou]u?)([^aou]*)$/

(Assume for the purposes of this exercise that the variable against
 which this match is being performed is a single word.)

It works, and is fine by me, but then, there may be a faster regex for
this problem (though this isn't slow, considering it's only against a
word at a time)... it's being used in the following substitution:

$plural =~ s/-/$noun/;
$plural =~ s/([aou]u?)([^aou]*)$/$accent{$1}$2/ if $plural =~ s/^"//;

Where the hash accent correlates the vowel or diphthong to its accented
version in German.  So, for example, if the word "Kopf" is the base
noun and '"-e' is input for the plural, this converts it to "Köpfe".
Same for "Mann" + '"-er' -> "Männer".

Thanks for any help you might be able to provide, and if I've forgotten
an diphthong that's umlauted when a word is made plural, please tell me
that, also (I've only had a year of German so far, making a vocabulary
quizzer so that I can control how my answers are scored better than
"quiz" does (I don't like all or nothing ;))...

Thanks,
Stevie

-- 
"First they came for the fourth amendment, but I said nothing because I 
wasn't a drug dealer. Then they came for the sixth amendment, but I kept 
quiet because I wasn't guilty. Finally they came for the first amendment,
and by then it was too late to say anything at all." -Nancy Lebowitz

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe