yanyiwu / cppjieba

"结巴"中文分词的C++版本
MIT License
2.57k stars 690 forks source link

Split的一个bug #108

Open dodng opened 6 years ago

dodng commented 6 years ago

您的Split函数实现如下: inline void Split(const string& src, vector& res, const string& pattern, size_t maxsplit = string::npos) { res.clear(); size_t Start = 0; size_t end = 0; string sub; while(Start < src.size()) { end = src.find_first_of(pattern, Start); if(string::npos == end || res.size() >= maxsplit) { sub = src.substr(Start); res.push_back(sub); return; } sub = src.substr(Start, end - Start); res.push_back(sub); Start = end + 1; } return; }

我拿来做http解析的时候发现功能异常。 示例数据如下: src: http\r\nlength\r\n\r\nhttp_body\r\n

pattern: \r\n\r\n

res: http length http_body

github-actions[bot] commented 1 week ago

This issue has not been updated for over 5 years and will be marked as stale. If the issue still exists, please comment or update the issue, otherwise it will be closed after 7 days.