728x90
반응형
설명은 나중에
#include <stdio.h>
#include <string>
#include <bits/stdc++.h>
#include <iostream>
#include <regex> // ⭐⭐
#define fastio ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;
int main() {
regex re("\\d");
string str;
while (true)
{
getline(cin, str);
//str : 검색 대상
//re : 정규식
if (std::regex_match(str, re))
cout << "Match" << endl;
else
cout << "No Match" << endl;
// 반복자를 이용하여 검사한 후 매치하는 부분만 출력
{
auto begin = std::sregex_iterator(str.begin(), str.end(), re);
auto end = std::sregex_iterator();
for (auto itr = begin; itr != end; ++itr)
{
std::smatch match = *itr;
cout << match.str() << " ";
}
cout << endl;
}
cout << endl;
}
return 0;
}
728x90
반응형
'IT > C++.C' 카테고리의 다른 글
c++ 에서 mybatis를 사용해보기.... (0) | 2024.04.23 |
---|---|
정규 표현식 예제2 - 설명추가(이걸 봐라.) (0) | 2024.02.02 |
ACE 강의를 볼수 있는곳 (0) | 2024.01.19 |
json-c-0.9 설치 (0) | 2024.01.05 |
ace 컴파일을 위해서 참조하고 있는 글들.... (0) | 2024.01.05 |
댓글