Return to Snippet

Revision: 51869
at October 6, 2011 14:48 by hyderai


Updated Code
//http://cc-cedict.org/wiki/start
     
    Pattern line_pattern = Pattern.compile("([^\\s]+)\\s([^\\s]+)\\s(\\[.+\\])\\s(/.+/)");
     
    Matcher matcher = line_pattern.matcher(line);
    boolean matchFound = matcher.find();
    while(matchFound) {
    System.out.println(matcher.start() + "-" + matcher.end());
    for(int i = 0; i <= matcher.groupCount(); i++) {
    String groupStr = matcher.group(i);
    System.out.println(i + ":" + groupStr);
    }
    if(matcher.end() + 1 <= line.length()) {
    matchFound = matcher.find(matcher.end());
    }
    else{
    break;
    }
    }
     
    T字帳 T字帐 [T zi4 zhang4] /T-account (accounting)/
    0-47
    0:T字帳 T字帐 [T zi4 zhang4] /T-account (accounting)/
    1:T字帳
    2:T字帐
    3:[T zi4 zhang4]
    4:/T-account (accounting)/

Revision: 51868
at October 6, 2011 14:46 by hyderai


Updated Code
//http://cc-cedict.org/wiki/start 測試

Pattern line_pattern = Pattern.compile("([^\\s]+)\\s([^\\s]+)\\s(\\[.+\\])\\s(/.+/)");	

Matcher matcher = line_pattern.matcher(line);
boolean matchFound = matcher.find();
while(matchFound) {
  System.out.println(matcher.start() + "-" + matcher.end());
  for(int i = 0; i <= matcher.groupCount(); i++) {
	String groupStr = matcher.group(i);
	System.out.println(i + ":" + groupStr);
  }
  if(matcher.end() + 1 <= line.length()) {
	matchFound = matcher.find(matcher.end());
  }
  else{
		break;
  }
}

T�帳 T�� [T zi4 zhang4] /T-account (accounting)/
result:
0-47
0:T�帳 T�� [T zi4 zhang4] /T-account (accounting)/
1:T�帳
2:T��
3:[T zi4 zhang4]
4:/T-account (accounting)/

Revision: 51867
at October 6, 2011 14:41 by hyderai


Updated Code
//http://cc-cedict.org/wiki/start 測試

Pattern line_pattern = Pattern.compile("([^\\s]+)\\s([^\\s]+)\\s(\\[.+\\])\\s(/.+/)");	

Matcher matcher = line_pattern.matcher(line);
boolean matchFound = matcher.find();
while(matchFound) {
  System.out.println(matcher.start() + "-" + matcher.end());
  for(int i = 0; i <= matcher.groupCount(); i++) {
	String groupStr = matcher.group(i);
	System.out.println(i + ":" + groupStr);
  }
  if(matcher.end() + 1 <= line.length()) {
	matchFound = matcher.find(matcher.end());
  }
  else{
		break;
  }
}

T字帳 T字帐 [T zi4 zhang4] /T-account (accounting)/
0-47
0:T字帳 T字帐 [T zi4 zhang4] /T-account (accounting)/
1:T字帳
2:T字帐
3:[T zi4 zhang4]
4:/T-account (accounting)/

Revision: 51866
at October 6, 2011 14:39 by hyderai


Updated Code
//http://cc-cedict.org/wiki/start 測試

Pattern line_pattern = Pattern.compile("([^\\s]+)\\s([^\\s]+)\\s(\\[.+\\])\\s(/.+/)");	

Matcher matcher = line_pattern.matcher(line);
boolean matchFound = matcher.find();
while(matchFound) {
  System.out.println(matcher.start() + "-" + matcher.end());
  for(int i = 0; i <= matcher.groupCount(); i++) {
	String groupStr = matcher.group(i);
	System.out.println(i + ":" + groupStr);
  }
  if(matcher.end() + 1 <= line.length()) {
	matchFound = matcher.find(matcher.end());
  }
  else{
		break;
  }
}

Revision: 51865
at October 6, 2011 14:31 by hyderai


Updated Code
//http://cc-cedict.org/wiki/start

Pattern line_pattern = Pattern.compile("([^\\s]+)\\s([^\\s]+)\\s(\\[.+\\])\\s(/.+/)");	

Matcher matcher = line_pattern.matcher(line);
boolean matchFound = matcher.find();
while(matchFound) {
  System.out.println(matcher.start() + "-" + matcher.end());
  for(int i = 0; i <= matcher.groupCount(); i++) {
	String groupStr = matcher.group(i);
	System.out.println(i + ":" + groupStr);
  }
  if(matcher.end() + 1 <= line.length()) {
	matchFound = matcher.find(matcher.end());
  }
  else{
		break;
  }
}

Revision: 51864
at October 6, 2011 14:27 by hyderai


Initial Code
//http://cc-cedict.org/wiki/start

Pattern line_pattern = Pattern.compile("([^\\s]+)\\s([^\\s]+)\\s(\\[.+\\])\\s(/.+/)");	

Matcher matcher = line_pattern.matcher(line);
boolean matchFound = matcher.find();
while(matchFound) {
  System.out.println(matcher.start() + "-" + matcher.end());
  for(int i = 0; i <= matcher.groupCount(); i++) {
	String groupStr = matcher.group(i);
	System.out.println(i + ":" + groupStr);
  }
  if(matcher.end() + 1 <= line.length()) {
	matchFound = matcher.find(matcher.end());
  }
  else{
		break;
  }
}
/*
T�¥�­ï¿½�¥�¸�³ T�¥�­ï¿½�¥�¸ï¿½ [T zi4 zhang4] /T-account (accounting)/
Result:
0-47
0:T�¥�­ï¿½�¥�¸�³ T�¥�­ï¿½�¥�¸ï¿½ [T zi4 zhang4] /T-account (accounting)/
1:T�¥�­ï¿½�¥�¸�³
2:T�¥�­ï¿½�¥�¸ï¿½
3:[T zi4 zhang4]
4:/T-account (accounting)/
*/

Initial URL

                                

Initial Description

                                

Initial Title
regular expression for CEDICT

Initial Tags

                                

Initial Language
Java