Getting character(s) of a string at specified positions

Ok, so lets say I have this:

myString = gets

I wanted to find what character is at position 5.

so if the use inputs

“How much wood would a wood-chuck chuck if a wood-chuck could chuck
wood”

I would find that the character there is “m”.

How would I find the fifth character?

Hi,

“How much wood would a wood-chuck chuck if a wood-chuck could chuck wood”

I would find that the character there is “m”.

How would I find the fifth character?

irb(main):001:0> a=“How much wood would a wood-chuck chuck if a
wood-chuck could chuck wood”
=> “How much wood would a wood-chuck chuck if a wood-chuck could chuck
wood”
irb(main):002:0> a[4,1]
=> “m”

M.

Matt Roth wrote:

“How much wood would a wood-chuck chuck if a wood-chuck could chuck wood”

I would find that the character there is “m”.

How would I find the fifth character?

myString[4].chr

or

myString[4, 1]

On 11/27/05, Alex F. [email protected] wrote:

or

myString[4, 1]

or

myString[4…4]

or

myString[4…5]

-austin