Sorry to be late to the party on this one, but a regex seems a bit of a =
big hammer. How about:

def article_for(noun)
  article =3D %w(a e i o u).include?(noun[0..0]) ? 'an' : 'a'
  "#{article} #{noun}"
end

irb(main):022:0> article_for 'dog'
=3D> "a dog"
irb(main):023:0> article_for 'animal'
=3D> "an animal"


On Oct 31, 2011, at 7:14 AM, Dave Aronson wrote:

> On Sun, Oct 30, 2011 at 22:23, jake kaiden <jakekaiden / yahoo.com> =
wrote:
>=20
>>  ruby Strings have an easy way of finding the first letter, the `[]`
>> method...  you can do something like this:
>>=20
>>  string =3D "hi there"
>>  puts string[0]
>>=20
>>  =3D> h
>=20
> In 1.9 yes... but many people are still on 1.8, which will give a
> number instead.  Gotta use string[0:0] instead.  :-(
>=20
>>  you could use a regular expression
>> (http://www.ruby-doc.org/core-1.9.2/Regexp.html) to determine whether =
to
>> put an "a" or an "an" before each word based on its first letter...
>=20
> If she's having a hard time extracting a character from a string, I
> don't think it's sporting to hit her with regexps quite yet.  ;-)
>=20
> -Dave
>=20
> --=20
> LOOKING FOR WORK! What: Ruby (on/off Rails), Python, other modern =
languages.
> Where: Northern Virginia, Washington DC (near Orange Line), and remote =
work.
> See: davearonson.com (main) * codosaur.us (code) * dare2xl.com =
(excellence).
> Specialization is for insects. (Heinlein) - Have Pun, Will Babble! =
(Aronson)
>=20