0
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 应该是什么,因为它是行尾???谁能帮我 ....

4

1 回答 1

2

为此,您最好使用 Regexp。

    Pattern p = Pattern.compile("Good morning (.*)");
    Matcher m = p.matcher(line[i]);
    String name = "";
    if (m.find())
        name = m.group(1);
于 2011-03-15T11:47:34.307 回答