[Java] 문자열에 문자열 찾기


[Java] 문자열에 문자열 찾기

들어가기 전문자열에 포함된 문자열을 찾고 싶었다. indexOf 는 문자열 안에 찾고 싶은 문자의 index 를 return 해주는 것이기에 내 의도와는 다르기 때문에 좀 더 깔끔한 것이 있나 확인해본 결과, 당연히 있었다. contains(CharSequence s)Returns true if and only if this string contains the specified sequence of char values. 사용예시String str = "내가 찾는 문자열"; if(str.contains("찾는")) {true;}else{false;} 참고# https://docs.oracle.com/javase/7/docs/api/java/lang/String.html


원문링크 : [Java] 문자열에 문자열 찾기