我正在尝试在字符串中找到模式,并且在获取最终结果时遇到一些麻烦。我有一个迭代字符串的方法,如果在输入字符串中找到子字符串,我将它添加到数组中:
boost::ioservice
输入字符串可能是string * maxRepeat(string input) {
string * matches = new string[22];
for(int i = 0; i < 22; i++) matches[i] = '@';
string s = input;
smatch m;
for(int i = 0; i < input.length()-1; i++){
for(int j = 0; j < input.length(); j++){
string foo = input.substr(j, j);
regex e("\\b(" + foo + ")([^ ]*)");
if (regex_search (input,m,e)) {
int index = 0;
for (auto x:m){
matches[index] = x;
index++;
}
}
i+=1;
}
}
return matches;
}
,我得到的最小字符串是249249249249
。如果只是249249
,我将如何执行此操作?