1
有什么RoR方法可以和preg_match_all()php函数一样工作吗?我们如何在RoR中使用preg_match_all()
有什么RoR方法可以和preg_match_all()php函数一样工作吗?我们如何在RoR中使用preg_match_all()
使用扫描:
string = '[email protected]; [email protected]'
result = string.scan(/([a-z0-9_.-]+)@([a-z0-9-]+)\.[a-z.]+/i)
p result.size
# => 2
p result
# => [["joe", "example"], ["walter", "example"]]
有一个很好的文章在这里:http://railsforphp.com/2008/01/17/regular-expressions-in-ruby/
我想作为输出[ '[email protected]', '[email protected]'] – ashok 2010-06-15 08:41:34