Finding the String

Discussion in 'Plugin Development' started by Jamesthatguy, May 19, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Jamesthatguy

    I have a quick question on how to do something. So what I want to do is define a string inside a sentence. For instance if I wanted to find the tenth letter of "Hello this is a test example thing" and define it in a string how would i do that?
     
  2. Offline

    caseif

    To get a given character:
    Code:
    String xCharacter = str.substring(x - 1, x);
    Where x is the index in the String of the character you want to get.
     
  3. Offline

    Jamesthatguy

    Alright, thanks for the quick reply!

    Also, do you know how I can find a specific letter/number in a string?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 1, 2016
  4. Offline

    caseif

    If you want to check if a String contains a certain character sequence, you can do the comparison:
    Code:
    if (!str.equals(str.replace("stringToSearchFor"))){
        // str contains String
    }
     
Thread Status:
Not open for further replies.

Share This Page