title: How to find, replace and break String containing xml into array?
body: <p>Let's say I have something like:</p>
  
  <pre><code>Sample 1: Your number is &lt;foo&gt;12345&lt;/foo&gt; and your code is &lt;foo&gt;29939&lt;/foo&gt;. 
  Sample 2: Your number is &lt;foo attr="x"&gt;12345&lt;/foo&gt; and your code is &lt;foo&gt;29939&lt;/foo&gt;. 
  </code></pre>
  
  <p>I would like to break this String into an array of string.</p>
  
  <p>Something like the following for Sample 1:</p>
  
  <pre><code>array[0] = Your number is
  array[1] = 12345
  array[2] = and your code is
  array[3] = 29939
  </code></pre>
  
  <p>Sample 2:</p>
  
  <pre><code>array[0] = Your number is
  array[1] = x|12345 (adding attr value to it)
  array[2] = and your code is
  array[3] = 29939
  </code></pre>
  
  <p>I am looking for <code>&lt;foo&gt;</code> with or without attribute in the String and need to break the String accordingly.</p>
  
  <p>I found an easy way to replace something under  with some value.</p>
  
  <p>Example: <code>matcher.replaceAll("bar")</code> which resulted in something like:</p>
  
  <pre><code>Your number is bar and your code is bar
  </code></pre>
  
  <p>What I would like to see is to the break the string into an array or list whenever I see the tag <code>&lt;foo&gt;</code> in the string value.</p>