// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.util.regex.*;

public class RegexSplit {
   private static Pattern p = Pattern.compile("[^\0]*[\0]");
   public static void process(String s) {
      Matcher m = p.matcher(s);
      int ix = 0;
      while(m.find()) {
         System.out.println("Complete string: " + m.group());
         ix = m.end();
      }
      if(ix < s.length()) {
         System.out.println("Incomplete string: " + s.substring(ix));
      }
   }
   public static void main(String[] args) {
      String s1 =  "a\0b\0";
      process(s1);
      String s2 =  "a\0b";
      process(s2);
   }
}
