-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathmain.cpp
49 lines (43 loc) · 1.03 KB
/
main.cpp
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
43
44
45
46
47
48
49
#include "re.h"
#include <iostream>
using namespace std;
int main()
{
RE re("ab|abcde");
string test_str;
test_str = "abcde";
if (re.match(test_str))
cout << test_str << "匹配成功" << endl;
else
cout << test_str << "匹配不成功" << endl;
test_str = "abcd";
if (re.match(test_str))
cout << test_str << "匹配成功" << endl;
else
cout << test_str << "匹配不成功" << endl;
test_str = "aadacaaaababcabcabcdabcde";
vector<string> result;
if (re.search(test_str, result))
{
for (auto it = result.begin(); it != result.end(); ++it)
cout << *it << endl;
}
re.replace("a(b|c)*");
test_str = "abcbcbc";
if (re.match(test_str))
cout << test_str << "匹配成功" << endl;
else
cout << test_str << "匹配不成功" << endl;
test_str = "abcbcd";
if (re.match(test_str))
cout << test_str << "匹配成功" << endl;
else
cout << test_str << "匹配不成功" << endl;
test_str = "abcbcdeaaabcbcbccccbacbfew";
if (re.search(test_str, result))
{
for (auto it = result.begin(); it != result.end(); ++it)
cout << *it << endl;
}
return 0;
}