How do I create a regular expression for this in android?

前端 未结 3 1842
野的像风
野的像风 2020-12-17 22:26

Suppose I have a string like this:

string = \"Manoj Kumar Kashyap\";

Now I want to create a regular expression to match where Ka appears af

3条回答
  •  一生所求
    2020-12-17 22:57

    You don't need a regular expression to do that. I'm not a Java expert, but according to the Android docs:

    public int indexOf (String string)
    Searches in this string for the first index of the specified string. The search for the string starts at the beginning and moves towards the end of this string.

    Parameters
    string the string to find.

    Returns
    the index of the first character of the specified string in this string, -1 if the specified string is not a substring.

    You'll probably end up with something like:

    int index = somestring.indexOf(" Ka");
    

提交回复
热议问题