From: Corey Haines Date: 2008-02-03T07:58:59+09:00 Subject: Re: Extracting vowels and consonants using regular expression ------=_Part_531_3884006.1201993145015 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Interesting. I guess you could post-process a bit on the two sets that you get back. A regular expression that can handle the y would be good, I guess. On Feb 2, 2008 5:40 PM, Donovan Dillon wrote: > Thanks Robert, Corey, Philip, Stephano, et. al, for all of the great > suggestions. However, they all seem to ignore the conditional nature of > 'y' > as a vowel. I would like the regex to treat 'y' as a vowel when there is > no > other vowel either before or after it. The string I used initially, was > drawn from the following perl code that accomplishes this (found at > http://www.perlmonks.org/?node_id=592867): > > > my @vowels = ( /[aeiou]|(? > The "(? > The "(?!...)" is a "zero-width negative-look-ahead assertion". > > Together, they match the condition of treating "y as a vowel only if there > is no other vowel before or after it." > > > This was my attempt at converting the Perl fragment to Ruby syntax: > > scan(/[aeiou]|(?![aeiou])y(?![aeiou])/i) > > I have since discovered that Ruby 1.8 lacks regex look-behind assertion -- > which explains why the code was failing. As a result, I have fallen back > to > the following which currently ignores the 'y': > > class String > def vowels > scan(/[aeiou]/i) > end > def consonants > scan(/[^aeiou]/i) > end > end > > > Any ideas how to modify this to include the conditional treatment of "y as > a > vowel only if there is no other vowel before or after it?" > > (i.e., is there a way to simulate the perl "zero-width > negative-look-behind" > and "zero-width negative-look-ahead" assertions for 'y' in Ruby 1.8?) > > > On 2/2/08 4:17 PM, in article > 335e48a90802021417n4ba96a11i746bd5118f18464e@mail.gmail.com, "Robert > Dober" > wrote: > > > Oh sorry using 1.9 excluseviley now... > > Robert > > > > > -- http://www.coreyhaines.com The Internet's Premiere source of information about Corey Haines ------=_Part_531_3884006.1201993145015--