0

I am having a hard time matching the following text:

<Reports>
   <Report active="1" valid="1" bureau="EXS"> Dummy Dummy</Report>
</Reports>

Using the following Regex:

/<Reports>.*<\/Reports>/

I am using rubular (I am using ruby) to test it , but I don't understand why my RegEx fails.

http://rubular.com/r/QEhgQ9Vgla

Any help?

  • obligatory link to http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags?page=1&tab=oldest#tab-top – RobP Dec 10 '14 at 15:58

2 Answers2

1

You need to include multiline modifier m.

/<Reports>.*<\/Reports>/m

DEMO

Avinash Raj
  • 172,303
  • 28
  • 230
  • 274
0

You could solve the problem with the help of REXML library.

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"
Arup Rakshit
  • 116,827
  • 30
  • 260
  • 317