【问题标题】:Configuration file format with space separator带空格分隔符的配置文件格式
【发布时间】:2013-05-06 12:26:51
【问题描述】:

我需要 Ruby gem 来处理文件,该文件包含参数名称和以空格分隔的值(比如 Unix 的 cfg/conf 文件格式)。以下是文件格式示例:

key value ; comment
foo 42
; bar comment

【问题讨论】:

    标签: ruby configuration gem file-format


    【解决方案1】:

    我认为你可以使用ruby-parseconfig,但你应该更改一个正则表达式

    param, value = line.split(/\s*=\s*/, 2)

    60 行中,将= 替换为空格(不记得如何在ruby 的正则表达式中写入空格)))

    【讨论】:

      猜你喜欢
      • 2013-05-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-27
      • 2013-07-18
      • 1970-01-01
      • 2014-08-02
      • 2017-09-07
      相关资源
      最近更新 更多