@@ -72,29 +72,31 @@ Regex::~Regex() {
72
72
73
73
74
74
std::list<SMatch> Regex::searchAll (const std::string& s) {
75
- int ovector[OVECCOUNT];
76
- std::list<SMatch> retList;
77
- int i;
78
75
const char *subject = s.c_str ();
79
- int rc;
80
76
const std::string tmpString = std::string (s.c_str (), s.size ());
77
+ int ovector[OVECCOUNT];
78
+ int rc, i, offset = 0 ;
79
+ std::list<SMatch> retList;
81
80
82
- rc = pcre_exec (m_pc, m_pce, subject,
83
- s.size (), 0 , 0 , ovector, OVECCOUNT);
84
-
85
- for (i = 0 ; i < rc; i++) {
86
- SMatch match;
87
- size_t start = ovector[2 *i];
88
- size_t end = ovector[2 *i+1 ];
89
- size_t len = end - start;
90
- if (end > s.size ()) {
91
- continue ;
81
+ do {
82
+ rc = pcre_exec (m_pc, m_pce, subject,
83
+ s.size () - offset, offset, 0 , ovector, OVECCOUNT);
84
+
85
+ for (i = 0 ; i < rc; i++) {
86
+ SMatch match;
87
+ size_t start = ovector[2 *i];
88
+ size_t end = ovector[2 *i+1 ];
89
+ size_t len = end - start;
90
+ if (end > s.size ()) {
91
+ continue ;
92
+ }
93
+ match.match = std::string (tmpString, start, len);
94
+ match.m_offset = start;
95
+ match.m_length = len;
96
+ offset = start + len;
97
+ retList.push_front (match);
92
98
}
93
- match.match = std::string (tmpString, start, len);
94
- match.m_offset = start;
95
- match.m_length = len;
96
- retList.push_front (match);
97
- }
99
+ } while (rc > 0 );
98
100
99
101
return retList;
100
102
}
0 commit comments