You can use character classes to match a range of characters rather than an exact match like this:
> str = "Daniel"
> match = /A-Za-z/.match str
=> nil
> match = /[A-Za-z]/.match str
=> #<MatchData "D">
The first example returned nil because "Daniel" does not match exactly to "A-Za-z". But the second example uses a character class where '-' has special meaning where it matches a range. So the regex engine checks the string and stops at the first occurance of a match, which is 'D' in this case.
Since the + modifier matches one or more occurances, I can return the full string this way:
> match = /[A-Za-z]+/.match str
=> #<MatchData "Daniel">
match[0] will provide the full string "Daniel" because the regex matched one or more occurences of essentially every letter in the alphabet.
With that knowledge, then the engine should also be able to match ALL a's in a string. But it doesn't:
> str = "Daaniaal"
> match = /[a]+/.match str
=> #<MatchData "aa">
It seemed to stop after it matched the first two a's, even I used + modifier to match one or MORE occurances. Would have expected a result like "aaaa". How come this doesn't work?