반응형
#include <iostream>
#include <string>
#include <regex>
int main() {
std::string logMessage = "데이터 오류 때문에 0 행이(가) 로드되지 않았습니다.";
std::regex errorMessageRegex("데이터 오류 때문에 (\\d+) 행이\\(가\\) 로드되지 않았습니다."); // 오류 메시지에 매칭되는 정규 표현식
std::smatch match;
if (std::regex_search(logMessage, match, errorMessageRegex)) {
std::string numberString = match[1].str(); // 추출된 숫자를 문자열로 저장
int number = std::stoi(numberString); // 문자열을 정수로 변환
std::cout << "로드되지 않은 행의 수: " << number << std::endl;
}
return 0;
}
반응형
'프로그래밍 _공부자료. > C++ 공부' 카테고리의 다른 글
std::byte 동적으로 메시지 수신받기 (0) | 2023.11.10 |
---|---|
c++ 파일 라인 함수명 출력하는 매크로 (0) | 2023.11.07 |
c++ 폴더를 생성하는 가장 간단한 방법 (0) | 2023.10.19 |
c++ 특정폴더 하위 디렉토리 출력하는법 (0) | 2023.10.19 |
c++ 이중벡터 사용법및 데이터 패키징하는법 (0) | 2023.10.18 |
댓글