我很难匹配以下案文:
<Reports>
<Report active="1" valid="1" bureau="EXS"> Dummy Dummy</Report>
</Reports>使用以下Regex:
/<Reports>.*<\/Reports>/我使用rubular (我使用ruby)来测试它,但是我不明白为什么我的RegEx会失败。
http://rubular.com/r/QEhgQ9Vgla有什么帮助吗?
发布于 2014-12-10 15:53:07
您需要包括多行修饰符m。
/<Reports>.*<\/Reports>/m演示
发布于 2014-12-10 16:54:01
您可以借助REXML库解决这个问题。
require 'rexml/document.rb'
doc = REXML::Document.new <<-DOC
<Reports>
<Report active="1" valid="1" bureau="EXS"> Dummy Dummy</Report>
</Reports>
DOC
doc.get_text("/Reports/Report") # => " Dummy Dummy"https://stackoverflow.com/questions/27405250
复制相似问题