담에 또 써먹을 일이 있을까 모르겠지만... 일단 끄적여 본다~
// 이 문자열에서 시간표시 이전만 남기고 제거하고 싶다.
String msg = "블라블라블라블라 (09:01 13:57:14) 블라블라블라";
String msgSubStr = ""; // 잘라낸 결과
Pattern pattern = Pattern.compile("\\(\\d\\d"); // 위 msg 문자열에서 "(09" 에 해당하는 정규식패턴
Matcher matcher = pattern.matcher(msg);
int foundIdx = 0;
if(matcher.find()){
foundIdx = matcher.start();
if(foundIdx > 1){
msgSubstr = msg.substring(0, foundIdx-1)
}
}
msgSubstr = msg.split(“\\(\\d\\d”)[0];//이렇게 해도 비슷한거같기도 하네요…
의견 감사해요~