我在正则表达式匹配 1) 使用 Rubular 时和 2) 在使用 rails 控制台或 irb 环境时有不同的输出。
1) 红色
/\w+/ on test string "---\n- nicidnut\n" matches " n nicidnut n"
(I have shown only matched part and put spaces for unmatched string characters)
2)IRB
(/\w+/).match("---\n- nicidnut\n") produces "nicidnut".
我不明白为什么有两个不同的输出,我错过了什么?