title: Extracting words from a pattern
body: <p>I have <code>String s = "#stack###over##flow".</code> How do I split <code>s</code> to have</p>
  
  <pre><code>String[] a = {"#", "stack", "###", "over", "##", "flow}
  </code></pre>
  
  <p>I tried <code>s.split("(?&lt;=#)|(?=#)")</code> as in <a href="https://stackoverflow.com/questions/2206378/how-to-split-a-string-but-also-keep-the-delimiters">How to split a string, but also keep the delimiters?</a> but it gives</p>
  
  <pre><code>String[] a = {"#", "stack", "#", "#", "#", "over", "#", "#", "flow}
  </code></pre>