title: Regex to capture groups
body: <p>My group could either be of the form x/y, x.y or x_y.z. Each group is separated by an underscore. The groups are unordered.</p>
  
  <p>Example:</p>
  
  <pre><code>ABC/DEF_abc.def_PQR/STU_ghi_jkl.mno
  </code></pre>
  
  <p>I would like to capture the following:</p>
  
  <pre><code>ABC/DEF
  abc.def
  PQR/STU
  ghi_jkl.mno
  </code></pre>
  
  <p>I have done this using a fairly verbose string iteration and parsing method (shown below), but am wondering if a simple regex can accomplish this.</p>
  
  <pre><code>private static ArrayList&lt;String&gt; go(String s){
      ArrayList&lt;String&gt; list = new ArrayList&lt;String&gt;();
      boolean inSlash = false;
      int pos = 0 ;
      boolean inDot = false;
      for(int i = 0 ; i &lt; s.length(); i++){
          char c = s.charAt(i);
          switch (c) {
          case '/':
              inSlash = true;
              break;
          case '_':
              if(inSlash){
                  list.add(s.substring(pos,i));
                  inSlash = false;
                  pos = i+1 ;
              }
              else if (inDot){
                  list.add(s.substring(pos,i));
                  inDot = false;
                  pos = i+1;
              }
              break;
          case '.':
              inDot = true;
              break;
          default:
              break;
          }
  
      }
      list.add(s.substring(pos));
      System.out.println(list);
      return list;
  }
  </code></pre>