-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathread_conf.cc
More file actions
43 lines (35 loc) · 1.09 KB
/
read_conf.cc
File metadata and controls
43 lines (35 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*+--------------------------------------------------------+
> File Name: tst.cc
> Author: TruJrong
> Mail: JrongTru@outlook.com
> Created Time: 2017年10月16日 星期一 18时00分06秒
+-------------------------------------------------------+*/
#include <iostream>
#include <regex>
#include <sstream>
#include <string>
#include <fstream>
using namespace std;
const string path("./ser.conf");
int main(int argc, char * argv[])
{
stringstream ss;
ifstream fin;
fin.open(path, ios::in);
string buf("");
string r_str("[^#]\\s*?(\\S+)?\\s*?=\\s*?(\\S+)\\s*?[#]?.*");
regex r(r_str);
smatch sm;
while(getline(fin, buf))
{
regex_match(buf, sm, r);
cout << "\n+---------------------------------------------------+" << endl;
cout << "string buffer: " << buf << endl;
for(int i = 0; i < sm.size(); ++i)
{
cout << "matched[" << i << "]: " << sm[i] << endl;
}
cout << "+---------------------------------------------------+" << endl;
}
return 0;
}