Your request for ...
Good morning Mr Praneel PIDIKITI
you have succ.....
这是我的字符串我想解析这个字符串以获得值Praneel PIDIKITI 我正在使用
int begin_index = 0;
int end_index = 0;
String startkeyword = "Good morning";
String endKeyword = " ???";
int main_begin_index = lines[i].indexOf(startkeyword, begin_index);
begin_index = main_begin_index;
end_index = lines[i].indexOf(endKeyword, begin_index);
String Name= lines[i].substring(begin_index + startkeyword.length(), end_index).trim();
什么应该是我的endKeyword,因为它是行的结尾??? 任何人都可以帮助我....
答案 0 :(得分:2)
你可能最好使用Regexp。
Pattern p = Pattern.compile("Good morning (.*)");
Matcher m = p.matcher(line[i]);
String name = "";
if (m.find())
name = m.group(1);