Fix error in "extractAllGroups" function

This commit is contained in:
Alexey Milovidov 2020-09-17 00:19:58 +03:00
parent 4a094491f2
commit c37b55c3b1
3 changed files with 8 additions and 2 deletions

View File

@ -129,7 +129,9 @@ public:
for (size_t group = 1; group <= groups_count; ++group)
data_col->insertData(matched_groups[group].data(), matched_groups[group].size());
pos = matched_groups[0].data() + matched_groups[0].size();
/// If match is empty - it's technically Ok but we have to shift one character nevertheless
/// to avoid infinite loop.
pos = matched_groups[0].data() + std::max<size_t>(1, matched_groups[0].size());
current_nested_offset += groups_count;
nested_offsets_data.push_back(current_nested_offset);
@ -167,7 +169,7 @@ public:
for (size_t group = 1; group <= groups_count; ++group)
all_matches.push_back(matched_groups[group]);
pos = matched_groups[0].data() + matched_groups[0].size();
pos = matched_groups[0].data() + std::max<size_t>(1, matched_groups[0].size());
++matches_per_row;
}

View File

@ -0,0 +1,2 @@
[[''],[''],[''],[''],[''],[''],['']]
[['','','','','','','']]

View File

@ -0,0 +1,2 @@
SELECT extractAllGroupsVertical('@#$%^&*', '(\w*)');
SELECT extractAllGroupsHorizontal('@#$%^&*', '(\w*)');