开发者

how can we use preg_match_all()in RoR

is there any RoR method which can work same as preg_match_all() p开发者_运维知识库hp function?


Use scan :

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"]]

there is a good article here: http://railsforphp.com/2008/01/17/regular-expressions-in-ruby/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜