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

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



On Mon, Aug 02, 1999 at 03:51:51PM -0400, Stevie Strickland wrote:
> 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.)

Would (/([aou]|au)/g)[-1] be simplest?  Could be slow if the string is large.

Maybe something with a negative lookahead... (coworker suggested this)

/([aou]|au)(?=[^aou]*$)/

I don't know if its relevant, but would something like Text::Metaphone
be helpful?  Dipthongs, phonemes... same diff.

-- 

Michael G Schwern                                           schwern@pobox.com
                    http://www.pobox.com/~schwern
     /(?:(?:(1)[.-]?)?\(?(\d{3})\)?[.-]?)?(\d{3})[.-]?(\d{4})(x\d+)?/i

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