I've written a very basic regex in Ruby for scraping email-addresses off the web. It looks like the following:
/\b\w+(\.\w+)*@\w+\.\w+(\.\w+)*\b/
When I load this into irb or rubular, I create the following string:
"example@live.com"
When I run the Regexp.match(string) command in irb, I get this:
regexp.match(string) =>#<MatchData "example@live.com" 1:nil 2:nil>
So the match seems to be recorded in the MatchData object. However, when I run the String.scan(regex) command (which is what I'm primarily interested in), I get the following:
string.scan(regex) => [[nil, nil]]
Why isn't scan returning the matched email address? Is it a problem with the regular expression? Or is it a nuance of String.scan/Regexp/MatchData that somebody could make me aware of?