Skip to main content

APIzation: Replication Package

[Q#26136020][A#26136178] how to split a string by ignoring the white space

https://stackoverflow.com/q/26136020

I need output as

Answer

https://stackoverflow.com/a/26136178

For your example you could change your split regex to something like this: This will match: Output: The regex character classes can be found on the documentation for Pattern

APIzation

String[] b = a.split("\\s(?!999)");
Value   :13131300100 999
Value   :13131300200 999
Value   :13131300300 999
Value   :13131300400 999
package com.stackoverflow.api;

public class Human26136178 {

  public static String[] specializedStringSplitter(String a) {
    return a.split("\\s(?!999)");
  }
}

package com.stackoverflow.api;

/**
 * how to split a string by ignoring the white space
 *
 * @author APIzator
 * @see <a href="https://stackoverflow.com/a/26136178">https://stackoverflow.com/a/26136178</a>
 */
public class APIzator26136178 {

  public static String[] splitString(String a) throws Exception {
    return a.split("\\s(?!999)");
  }
}