title: How do I split string using String.split() without having trailing/leading spaces or empty values?
body: <p>How do I split string using String.split() without having trailing/leading spaces or empty values?</p>
  
  <p>Let's say I have string such as <code>"  ol-ga@assf-rrt.ru  ; sdf.an@dfgdfg.com;   sdfsdf@fdfd.erff,  privet@vvv.fff  "</code>.</p>
  
  <p>I used to split it by calling <code>String.split("[;, ]+")</code> but drawback is that you get empty array elements that you need to ignore in extra loop.</p>
  
  <p>I also tried <code>String.split("\\s*[;,]+\\s*")</code> which doesn't give empty elements but leaves leading space in first email and trailing space in last email so that resulting array looks like because there are no commas or semicolons next to those emails:</p>
  
  <pre><code>[0] = {java.lang.String@97}"  ol-ga@assf-rrt.ru"
  [1] = {java.lang.String@98}"sdf.an@dfgdfg.com"
  [2] = {java.lang.String@99}"sdfsdf@fdfd.erff"
  [3] = {java.lang.String@100}"privet@vvv.fff  "
  </code></pre>
  
  <p>Is it possible to get array of "clean" emails using only regex and Split <strong>(without using extra call to String.trim())</strong> ?</p>
  
  <p>Thanks!</p>