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