-2
현재 특정 문자열 안에 Hello world를 추출하고 싶습니다. 현재 처음 및 마지막 Occurences.there에 문자열이 있습니다. 각 특정 문자열에 문자열이 3 개 있습니다.문자열 내에서 항목 추출
String text="hellogfddfdfsdsworldhelloasaasasdasdggworldfdfdsdhellodasasddworld";
int x=text.indexOf("hello");
int y=text.indexOf("world");
String test=text.substring(x, y+4);
System.out.println(test);
x=text.indexOf("hello");
y=text.indexOf("world");
String test1=text.substring(x,y);
System.out.println(test1);
x=text.lastIndexOf("hello");
y=text.lastIndexOf("world);
String test2=text.substring(x, y);
System.out.println(test2);
전문가는 아니지만 '정규식'이 사용자의 필요를 충족시킬 수 있다고 생각합니다! – SudoRahul