title: Custom String split method in java
body: <p>I am trying to implement a custom split string method and I am getting lost in for loops.  I will post my code so far and hopefully someone can tell me where I am going wrong.  I know there are better ways to do this, but I am just wondering why I can't seem to get the for loops to read properly.  Basically I want to be able to set multiple delimiters at once.  So I was populating a an array of just the delimiters and trying to compare each character in the full string with each entry in the delimiter Array.  If it was not a delimiter, it added it to a string, if it was, it broke off the loop and took the string it created and added it to the first entry in the string array.  This should continue until the character array was done.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>    String[] charArray = new String[s.length()];
      String[] stringArray = new String[s.length()];
      String[] delimArray = new String[regex.length()];
  
      // Fill array with delimiter values
      for (int i=0; i &lt; delimArray.length; i++) {
          delimArray[i] = Character.toString(regex.charAt(i));
      }
  
      // Fill array with all values in string by character
      for (int i=0; i &lt; charArray.length; i++) {
          charArray[i] = Character.toString(s.charAt(i));
      }
  
      for (int i=0; i &lt; stringArray.length; i++) {
          String s1 = "";
          for (int k=0; k &lt; charArray.length; k++) {
              for (int j=0; j &lt; delimArray.length; j++) {
                  if  (charArray[k] != delimArray[j]) {
                      s1 = s1 + charArray[k];
                  } else if (charArray[k] == delimArray[j]) {
                      stringArray[i+1] = delimArray[j];
                      break;
                  }
              }
              s1 = s1 + charArray[k];
          }
          stringArray[i] = s1;
      }
  </code></pre>