Ruby on rails 我们如何在RoR中使用preg_match_all()

Ruby on rails 我们如何在RoR中使用preg_match_all(),ruby-on-rails,Ruby On Rails,是否有任何RoR方法可以与preg_match_all()php函数一样工作?使用扫描: string = 'joe@example.com; walter@example.org' result = string.scan(/([a-z0-9_.-]+)@([a-z0-9-]+)\.[a-z.]+/i) p result.size # => 2 p result # => [["joe", "example"], ["walter", "example"]] 这里有一篇好文章:

是否有任何RoR方法可以与preg_match_all()php函数一样工作?

使用扫描:

string = 'joe@example.com; walter@example.org'
result = string.scan(/([a-z0-9_.-]+)@([a-z0-9-]+)\.[a-z.]+/i)
p result.size
# => 2

p result
# => [["joe", "example"], ["walter", "example"]]

这里有一篇好文章:

我希望输出为['joe@example.com','walter@example.org']