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>