- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathregex.cpp
More file actions
Latest commit
19 lines (15 loc) · 443 Bytes
/
Copy pathregex.cpp
File metadata and controls
19 lines (15 loc) · 443 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
For loop and smatch and .suffix() with regex_search
https://ideone.com/jRsAWd
*/
#include<regex>
#include<iostream>
#include<string>
intmain()
{
std::string str = "\"one\":\"1\", \"two\":2, \"two\":44, \"three\":3, \"two\":22 ";
std::string const expr{ "\"two\":(\\d+)" };
for (std::smatch matches; std::regex_search(str, matches, std::regex(expr)); str = matches.suffix())
std::cout << matches[1] << std::endl;
return0;
}