Question: I am going through the Peter Cooper book "Beginning Ruby" and I have some questions regarding some of the string methods and regular expression usage. I think I'm clear on what a regular expression is: "a string that describes a pattern for matching elements in other strings."

So:

```
"This is a test".scan(/\w\w/) {|x| puts x}

Output:
Th
is
is
te
st
=> "This is a test"

```

1. So it prints two characters at a time. I didn't realize it also returns the original string. Why is this?

Also, 

```
    "This is a test".scan(/[aeiou]/) { |x| puts x }

```

2. What do the brackets do? I think they are called character classes, but I am not sure exactly what they do. The explanation in Cooper's book isn't totally verbose and clear.

Explanation of character classes:

> 
> "The last important aspect of regular expressions you need to understand at this stage is
>  character classes. These allow you to match against a specific set of characters. For example, you can scan through all the vowels in a string:"
> 
> 
>

Answer: 
This is because you declare body and head to be WITHIN the while loop. To fix this, create the variables before the 

```
while (!done)

```

iterates.
Your body and head variable is initialized inside the while loop that's why it is reset to zero every time. Just move out these variables from the while loop.

Initialize you variable inside the loop when you want to reset your variable value on each iteration or If you want to keep maintain you update value with in the loop than initialized those variable outside the loop.