Greetings,

On 1/29/06, Jeppe Jakobsen <jeppe88 / gmail.com> wrote:
> Lets say that I have a variable:
>
> aString = "1234s * 4234k"
>
> I'll then like to scan for the units (the s and the k) after each integer:
>
> anArray = aString.scan(/s/)
>
> Well that got me the s, but what expression do I have to use, if I want to
> scan for both s and k?

if you have an explicit list:
  anArray = aString.scan(/[sk]/)  #=>  ["s", "k"]

if you just want any lowercase letter:
  anArray = aString.scan(/[a-z]/) #=>  ["s", "k"]

String.scan takes a regex, you might want to look into that.  Have fun!

Cameron