This question shows research effort; it is useful and clear
-3
This question does not show any research effort; it is unclear or not useful
Bookmark this question.
Show activity on this post.
为什么一个正则表达式对扫描和匹配方法的行为不同?
str = "A man, a plan, a canal -- Panama"
/\w+/.match(str).to_s #=> #<MatchData "A"> i.e. just "A"
str.scan(/\w+/) #=> ["A", "man", "a", "plan", "a", "canal", "Panama"]