Ruby - parsing a text file

前端 未结 2 921
眼角桃花
眼角桃花 2020-12-30 04:59

I am pretty new to Ruby and have been trying some really basic text parsing. I am now however trying to parse a little bit more of a complicated file and then push it out in

2条回答
  •  攒了一身酷
    2020-12-30 05:50

    Here's a general idea for you to start with

    File.open( thefile ).each do |line|
        print line without the new line if line does not contain  /--+/
        if line contains /--+/
            print line with a new line
        end
    end
    

提交回复
热议问题