title: Use regex to un camelCase Java String
body: <p>This code seems to work perfectly, but I'd love to clean it up with regex.</p>
  
  <pre><code> public static void main(String args[]) {
      String s = "IAmASentenceInCamelCaseWithNumbers500And1And37";
      System.out.println(unCamelCase(s));
  }
  
  public static String unCamelCase(String string) {
      StringBuilder newString = new StringBuilder(string.length() * 2);
      newString.append(string.charAt(0));
      for (int i = 1; i &lt; string.length(); i++) {
          if (Character.isUpperCase(string.charAt(i)) &amp;&amp; string.charAt(i - 1) != ' '
              || Character.isDigit(string.charAt(i)) &amp;&amp; !Character.isDigit(string.charAt(i - 1))) {
              newString.append(' ');
          }
          newString.append(string.charAt(i));
      }
      return newString.toString();
  }
  </code></pre>
  
  <p>Input:</p>
  
  <pre><code>IAmASentenceInCamelCaseWithNumbers500And1And37
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>I Am A Sentence In Camel Case With Numbers 500 And 1 And 37
  </code></pre>
  
  <p>I'm not a fan of using  that ugly if statement, and I'm hoping there's a way to use a single line of code that utilizes regex. I tried for a bit but it would fail on words with 1 or 2 letters.</p>
  
  <p>Failing code that doesn't work:</p>
  
  <pre><code>return string.replaceAll("(.)([A-Z0-9]\\w)", "$1 $2");
  </code></pre>