comparison 3rdparty/vmime/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-regex.cpp @ 0:a4671277546c tip

created the repository for the thymian project
author ferencd
date Tue, 17 Aug 2021 11:19:54 +0200
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:a4671277546c
1 #include <algorithm>
2 #include <regex>
3
4 int parse_line(std::string const& line)
5 {
6 std::string tmp;
7 if(std::regex_search(line, std::regex("(\\s)+(-)?(\\d)+//(-)?(\\d)+(\\s)+"))) {
8 tmp = std::regex_replace(line, std::regex("(-)?(\\d)+//(-)?(\\d)+"), std::string("V"));
9 } else if(std::regex_search(line, std::regex("(\\s)+(-)?(\\d)+/(-)?(\\d)+(\\s)+"))) {
10 tmp = std::regex_replace(line, std::regex("(-)?(\\d)+/(-)?(\\d)+"), std::string("V"));
11 } else if(std::regex_search(line, std::regex("(\\s)+(-)?(\\d)+/(-)?(\\d)+/(-)?(\\d)+(\\s)+"))) {
12 tmp = std::regex_replace(line, std::regex("(-)?(\\d)+/(-)?(\\d)+/(-)?(\\d)+"), std::string("V"));
13 } else {
14 tmp = std::regex_replace(line, std::regex("(-)?(\\d)+"), std::string("V"));
15 }
16 return static_cast<int>(std::count(tmp.begin(), tmp.end(), 'V'));
17 }
18
19 int main()
20 {
21 bool test = (parse_line("f 7/7/7 -3/3/-3 2/-2/2") == 3) &&
22 (parse_line("f 7//7 3//-3 -2//2") == 3) &&
23 (parse_line("f 7/7 3/-3 -2/2") == 3) &&
24 (parse_line("f 7 3 -2") == 3);
25 return test ? 0 : 1;
26 }