【发布时间】:2011-06-18 08:05:36
【问题描述】:
我有一个主题标题用“|”括起来的文档字符。
例如"| 链接 |"
我想检查字符串是否以“|”开头和结尾用于验证特定文档的主题标题是否有效的字符。我该怎么做?
来源:
@filetarget = " < document file location here > "
@line = ""
file = File.new(@filetarget)
while (@line = file.gets)
if((@line.start_with?("|")) and (@line.end_with?("|")))
puts "Putting: " + @line
end
end
用于解析的文档文本:
| LINKS |
http://www.extremeprogramming.org/ <1>
http://c2.com/cgi/wiki?ExtremeProgramming <2>
http://xprogramming.com/index.php <3>
| COMMENTS |
* Test comment
* Test comment 2
* Test comment 3
【问题讨论】:
标签: ruby regex string-parsing