title: Remove and get text, from comma separated string if it has # as prefix in java?
body: <p>I have a string in java as</p>
  <p><strong>Input</strong></p>
  <pre><code>String str = &quot;1,2,3,11,#5,#7,9&quot;;
  </code></pre>
  <p><strong>Output Desired</strong></p>
  <pre><code>String result = &quot;1,2,3,11,9&quot;;
  // And 5,7 with special character # in separate Array-list
  //List&lt;String&gt; list = [&quot;5&quot;,&quot;7&quot;];
  </code></pre>
  <p><strong>Note</strong>: This special character <strong>#</strong> is dynamic, it may or may not be present in string.</p>
  <p>I know how to remove # using str.replaceAll(&quot;#&quot;, &quot;&quot;);, but how to get 5 and 7 in a separate list.</p>