Find the words start from a special character java

后端 未结 5 1651
梦毁少年i
梦毁少年i 2021-02-08 21:18

I want to find the words that start with a \"#\" sign in a string in java. There can be spaces between the sign and the word as well.

The string \"hi #how are # yo

5条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-08 21:49

         String mSentence = "The quick brown fox jumped over the lazy dog."; 
    
          int juIndex = mSentence.indexOf("ju");
          System.out.println("position of jumped= "+juIndex);
          System.out.println(mSentence.substring(juIndex, juIndex+15));
    
          output : jumped over the
          its working code...enjoy:)
    

提交回复
热议问题