From: Andrew Stewart Date: 2008-01-17T01:52:29+09:00 Subject: Re: regular expression On 16 Jan 2008, at 15:57, Johnathan Smith wrote: > i wanting to write a regular expression which matches words which > contain the vowels [aeiou] in alphabetical order > > im not sure where to start so any help would be greatly appreciated This will get you started: IRB: >> re = /[^aeiou]*[a][^aeiou]*[e][^aeiou]*[i][^aeiou]*[o][^aeiou]*[u] [^aeiou]*/ => [aeiou][a][aeiou][e][aeiou][i][aeiou][o][aeiou][u][aeiou] >> 'abstemious' =~ re => 0 >> 'facetious' =~ re => 0 >> 'bstemious' =~ re => nil >> 'ebstamious' =~ re => nil You can see there's a lot of repetition in the regular expression so the next step would probably be to DRY it. I leave that as an exercise to the reader (because I can't work out how to do it :) You'll may also wish to anchor the regular expression so it doesn't cross words. Regards, Andy Stewart ------- http://airbladesoftware.com