MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / MatchAll

Method MatchAll

extensions/regex/CRegEx.cpp:128–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126}
127
128int RegEx::MatchAll(const char *str)
129{
130 int rc = 0;
131
132 if (mFree || re == nullptr)
133 return -1;
134
135 this->ClearMatch();
136
137 //save str
138 subject = strdup(str);
139 size_t len = strlen(subject);
140
141 size_t offset = 0;
142 unsigned int matches = 0;
143
144 while (matches < MAX_MATCHES && offset < len && (rc = pcre_exec(re, 0, subject, len, offset, 0, mMatches[matches].mVector, MAX_CAPTURES)) >= 0)
145 {
146 offset = mMatches[matches].mVector[1];
147 mMatches[matches].mSubStringCount = rc;
148
149 matches++;
150 }
151
152 if (rc < PCRE_ERROR_NOMATCH || (rc == PCRE_ERROR_NOMATCH && matches == 0))
153 {
154 if (rc == PCRE_ERROR_NOMATCH)
155 {
156 return 0;
157 }
158 else {
159 mErrorCode = rc;
160 return -1;
161 }
162 }
163
164 mMatchCount = matches;
165
166 return 1;
167}
168
169void RegEx::ClearMatch()
170{

Callers 1

MatchRegexAllFunction · 0.80

Calls 1

ClearMatchMethod · 0.95

Tested by

no test coverage detected