1 개요[ | ]
- C++ preg_split_delim_capture() 구현
2 aaa1bbb2ccc[ | ]
C++
Copy
#include <iostream>
#include <vector>
#include <regex>
using namespace std;
int main() {
string s("aaa1bbb2ccc");
regex r("([0-9])");
vector<std::string> tokens(sregex_token_iterator(s.begin(), s.end(), r, {-1, 0}), sregex_token_iterator());
for (string t: tokens) cout << t << ", "; // aaa, 1, bbb, 2, ccc,
}
Loading
3 123aaa[ | ]
C++
Copy
#include <iostream>
#include <vector>
#include <regex>
using namespace std;
int main() {
string s("123aaa");
regex r("([0-9])");
vector<std::string> tokens(sregex_token_iterator(s.begin(), s.end(), r, {-1, 0}), sregex_token_iterator());
for (string t: tokens) cout << t << ", "; // , 1, , 2, , 3, aaa,
}
Loading
4 같이 보기[ | ]
편집자 Jmnote
로그인하시면 댓글을 쓸 수 있습니다.