re = /\<p\s+?\/\>[ ]?/
str = '<?xml version="1.0" encoding="utf-8"?>
<Data>
<Text number="1">
<Title>Lazy dog jumper</Title>
<Description><arg format="x" /><p /> The quick <p /> brown fox <p /> jumps <p /> over the <p /> lazy dog.<p />The quick brown fox jumps <p />over the lazy dog.<p /> The quick brown fox jumps over the lazy dog. <p /></Description>
</Text>
<Text number="2">
<Title>Lazy foxer</Title>
<Description>The quick brown fox <arg format="x" /><p />jumps <p>asdf</p> over the lazy dog <p /></Description>
</Text>
<Text number="3">
<Title>Quickest jumper</Title>
<Description>The quickest brown fox jumps over the lazy dog <p /> The slowest brown fox jumps over the laziest dog. <p /></Description>
</Text>
</Data>'
# Print the match result
str.scan(re) do |match|
puts match.to_s
end
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html