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

前端 未结 3 1840
野的像风
野的像风 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:45

    You can use regular expressions just like in Java SE:

    Pattern pattern = Pattern.compile(".* (Ka).*");
    Matcher matcher = pattern.matcher("Manoj Kumar Kashyap");
    if(matcher.matches())
    {
        int idx = matcher.start(1);
    }

提交回复
热议问题