All pastes #839380 Raw Edit

ymo

public text v1 · immutable
#839380 ·published 2007-12-31 00:15 UTC
rendered paste body

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author ymo
 * 
 */
public class Main {

   protected static Pattern wordToken;
   protected static Pattern lineToken;

   protected static String line = "<Y> ,<X> ,";

   public static void main(String[] args) {
      lineToken = Pattern.compile("(.*<X>)?(.*<Y>)?");

      Matcher m = lineToken.matcher(line); // Create Matcher
      
      for (;m.find();) {
         
         String s = m.group();
         
         if(s.length()!=0){
            System.out.println(m.start()+":"+m.end()+":"+m.group());
         }
      }
   }

}

---
0:8:<Y> ,<X>