title: Split string on whitespace OR dash only. Java Applet
body: <p>I'm trying to split a space AND a dash character between words in a string array. The following code shows what kind of result I am after.</p>
  
  <p>Code:</p>
  
  <pre><code>String[] wordSplit = txtInput.split (" ") &amp;&amp; txtInput.split ("-");
  </code></pre>
  
  <p>input:</p>
  
  <pre><code>hello world hello-world
  </code></pre>
  
  <p>expected output:</p>
  
  <pre><code>there are: 4 word(s) of length 5.
  </code></pre>