Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find char index where contains() found sequence

Tags:

java

string

    if(input.contains("Angle ")) {
        input.charAt(?);
    }

So, basically, how would you find the char directly after "Angle "? In absolute simplest terms, how do you find the indexes in which "Angle " was found?

like image 813
QuaternionsRock Avatar asked Oct 01 '22 06:10

QuaternionsRock


1 Answers

You can use the indexOf method both to find out that the input contains the string, and where its index is:

int pos = input.indexOf("Angle ");
if (pos >= 0) {
    ... // Substring is found at index pos
}
like image 96
Sergey Kalinichenko Avatar answered Oct 05 '22 11:10

Sergey Kalinichenko