bugfixes
This commit is contained in:
@@ -98,6 +98,20 @@ std::vector<std::string> split(std::string s, std::string delimiter) {
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<std::wstring> split(std::wstring s, std::wstring delimiter) {
|
||||
std::vector<std::wstring> result;
|
||||
size_t pos = 0;
|
||||
std::wstring token;
|
||||
while ((pos = s.find(delimiter)) != std::string::npos) {
|
||||
token = s.substr(0, pos);
|
||||
result.push_back(token);
|
||||
s.erase(0, pos + delimiter.length());
|
||||
}
|
||||
result.push_back(s);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::wstring substring_from_to(std::wstring& text, std::wstring from, std::wstring to) {
|
||||
unsigned int start_pos = 0;
|
||||
unsigned int end_pos = 0;
|
||||
@@ -169,12 +183,13 @@ std::vector<std::wstring> find_amounts_in_html(std::string html) {
|
||||
std::vector<std::wstring> find_net_weights_in_names(std::vector<std::wstring> &names) {
|
||||
std::vector<std::wstring> result;
|
||||
for (std::wstring &name : names ) {
|
||||
boost::wregex regexp(from_utf8("((\\d+(.|,)?\\d?((м|)л|(к|м|)г|т|ц|шт|(pc|)s|(m|k|)g|(m|)l|t)).?)+"), boost::regex_constants::collate);
|
||||
boost::wregex regexp(from_utf8("((\\d+(\\.|,)?\\d{0,}((м|)л|(к|м|)г|т|ц|шт|(pc|)s|(m|k|)g|(m|)l|t))(\\s|\\t){0,})+"), boost::regex_constants::collate);
|
||||
bool found = false;
|
||||
for (boost::wsregex_iterator it{name.begin(), name.end(), regexp}, end{}; it != end;
|
||||
it++) {
|
||||
result.push_back(it->str());
|
||||
found = true;
|
||||
name.erase(it->position(), it->str().length());
|
||||
break;
|
||||
}
|
||||
if (!found) {
|
||||
|
||||
@@ -17,6 +17,7 @@ bool areAllSizesEqual(const std::vector<T>& v1, const std::vector<T>& v2,
|
||||
const std::vector<T>& v3, const std::vector<T>& v4);
|
||||
|
||||
std::vector<std::string> split(std::string, std::string);
|
||||
std::vector<std::wstring> split(std::wstring s, std::wstring delimiter);
|
||||
|
||||
#ifdef BUILD_OFD_MODE
|
||||
Check parseOfdRuAnswer(std::string);
|
||||
|
||||
Reference in New Issue
Block a user