Last active
October 12, 2023 12:59
-
-
Save Cryolitia/10424e4c5a1fc9ec9e1e3f3fbfb1a6bd to your computer and use it in GitHub Desktop.
Regex single UTF-8 Character in std::string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <regex> | |
int main() { | |
std::string input = "你好,world!"; | |
std::smatch matches; | |
auto regex = std::regex("([\\x00-\\x7F]|([\\xC0-\\xF7][\\x80-\\xBF]*))"); | |
std::sregex_iterator begin(input.begin(),input.end(),regex); | |
std::sregex_iterator end; | |
for (auto i = begin;i!=end;++i) { | |
std::cout<<"Match: "<<i->str()<<std::endl; | |
} | |
return 0; | |
} |
Author
Cryolitia
commented
Oct 12, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment