2012-01-27 20 views
0

如何從位置(示例)5中讀取字符串到java中字符串的末尾。以書面形式發出正則表達

QRegExp StripType(re, Qt::CaseInsensitive); 
    int p = StripType.indexIn(line, 0); 
    int len = StripType.matchedLength(); 
    String tmp += line.mid(len); 

如何QT轉換成Java

如果再在上面的代碼是正則表達式,我想上面的隱蔽到Java我曾嘗試

String s =pattern.toString(); 
int pos = s.indexOf(line); 
Matcher matcher = Pattern.compile(re).matcher(line); 
if (matcher.find()) { 
System.out.println(matcher.group()); 
} else { 
System.out.println("String contains no character other than that"); 
} 
len = matcher.start(); 

但它不工作正確 由於提前

回答

0

首先,你應該添加Pattern.CASE_INSENSITIVE標誌。

Matcher matcher = Pattern.compile(re, Pattern.CASE_INSENSITIVE).matcher(line);