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 应该是什么,因为它是行尾??? 谁能帮助我....
最佳答案
为此,您最好使用正则表达式。
Pattern p = Pattern.compile("Good morning (.*)");
Matcher m = p.matcher(line[i]);
String name = "";
if (m.find())
name = m.group(1);
关于java - 解析字符串 - 换行符的结束索引应该是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5310989/