我有以下文字:
…,Niedersachsen,NOT IN CHARGE SINCE: 03.2009, CATEGORY:…,
现在我想在NOT IN CHARGE SINCE之后提取日期:直到逗号.
所以我只需要03.2009作为我的子串的结果.
那我怎么办呢?
String substr = "not in charge since:";
String before = s.substring(0, s.indexOf(substr));
String after = s.substring(s.indexOf(substr),s.lastIndexOf(","));
编辑
for (String s : split) {
s = s.toLowerCase();
if (s.contains("ex peps")) {
String substr = "not in charge since:";
String before = s.substring(0, s.indexOf(substr));
String after = s.substring(s.indexOf(substr), s.lastIndexOf(","));
System.out.println(before);
System.out.println(after);
System.out.println("PEP!!!");
} else {
System.out.println("Line ok");
}
}
但这不是我想要的结果.