title: Java String.split() Regex
body: <p>I have a string: </p>
  
  <pre><code>String str = "a + b - c * d / e &lt; f &gt; g &gt;= h &lt;= i == j";
  </code></pre>
  
  <p>I want to split the string on all of the operators, but include the operators in the array, so the resulting array looks like:</p>
  
  <pre><code>[a , +,  b , -,  c , *,  d , /,  e , &lt;,  f , &gt;,  g , &gt;=,  h , &lt;=,  i , ==,  j]
  </code></pre>
  
  <p>I've got this currently:</p>
  
  <pre><code>public static void main(String[] args) {
      String str = "a + b - c * d / e &lt; f &gt; g &gt;= h &lt;= i == j";
      String reg = "((?&lt;=[&lt;=|&gt;=|==|\\+|\\*|\\-|&lt;|&gt;|/|=])|(?=[&lt;=|&gt;=|==|\\+|\\*|\\-|&lt;|&gt;|/|=]))";
  
      String[] res = str.split(reg);
      System.out.println(Arrays.toString(res));
  }
  </code></pre>
  
  <p>This is pretty close, it gives: </p>
  
  <pre><code>[a , +,  b , -,  c , *,  d , /,  e , &lt;,  f , &gt;,  g , &gt;, =,  h , &lt;, =,  i , =, =,  j]
  </code></pre>
  
  <p>Is there something I can do to this to make the multiple character operators appear in the array like I want them to?</p>
  
  <p>And as a secondary question that isn't nearly as important, is there a way in the regex to trim the whitespace off from around the letters?</p>