ruby正则表达式(删除字符)

时间:2013-03-07 00:38:12

标签: ruby-on-rails ruby regex

我从数据库中获取一些结果:

@log_detail = connection.execute("SELECT logs,setup FROM mastertest WHERE test_ins_id LIKE blah blah blah");

结果

 logs = a/atf/something
 setup = tb-1-atf with ac-2115 

我想要

logs = atf/something
setup = 2115

我尝试了以下日志,但它似乎无法正常工作

@log_detail.each do |row|
    row[0] = row[0].drop(2) 
end

1 个答案:

答案 0 :(得分:1)

尝试:

row[0] = row[0][2..-1]

并查看String上的[]方法。