Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert regex $/EOL end-of-string new-line special case handling #9774

Merged
merged 4 commits into from
Dec 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions cpp/src/strings/regex/regex.inl
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,7 @@ __device__ inline int32_t reprog_device::regexec(
}
break;
case EOL:
if (last_character ||
(c == '\n' && (inst->u1.c == '$' ||
// edge case where \n appears at the end of the string
pos + 1 == dstr.length()))) {
if (last_character || (c == '\n' && inst->u1.c == '$')) {
id_activate = inst->u2.next_id;
expanded = true;
}
Expand Down
6 changes: 3 additions & 3 deletions cpp/tests/strings/contains_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,21 +310,21 @@ TEST_F(StringsContainsTests, MultiLine)
auto expected_contains = cudf::test::fixed_width_column_wrapper<bool>({1, 1, 1, 0, 1});
CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*results, expected_contains);
results = cudf::strings::contains_re(view, "^abc$");
expected_contains = cudf::test::fixed_width_column_wrapper<bool>({0, 0, 1, 0, 1});
expected_contains = cudf::test::fixed_width_column_wrapper<bool>({0, 0, 1, 0, 0});
CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*results, expected_contains);

results = cudf::strings::matches_re(view, "^abc$", cudf::strings::regex_flags::MULTILINE);
auto expected_matches = cudf::test::fixed_width_column_wrapper<bool>({1, 0, 1, 0, 1});
CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*results, expected_matches);
results = cudf::strings::matches_re(view, "^abc$");
expected_matches = cudf::test::fixed_width_column_wrapper<bool>({0, 0, 1, 0, 1});
expected_matches = cudf::test::fixed_width_column_wrapper<bool>({0, 0, 1, 0, 0});
CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*results, expected_matches);

results = cudf::strings::count_re(view, "^abc$", cudf::strings::regex_flags::MULTILINE);
auto expected_count = cudf::test::fixed_width_column_wrapper<int32_t>({2, 1, 1, 0, 1});
CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*results, expected_count);
results = cudf::strings::count_re(view, "^abc$");
expected_count = cudf::test::fixed_width_column_wrapper<int32_t>({0, 0, 1, 0, 1});
expected_count = cudf::test::fixed_width_column_wrapper<int32_t>({0, 0, 1, 0, 0});
CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*results, expected_count);
}

Expand Down
2 changes: 1 addition & 1 deletion python/cudf/cudf/tests/test_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -1746,7 +1746,7 @@ def test_string_wrap(data, width):
["A B", "1.5", "3,000"],
["23", "³", "⅕", ""],
[" ", "\t\r\n ", ""],
["$", "B", "Aab$", "$$ca", "C$B$", "cat", "cat\n"],
["$", "B", "Aab$", "$$ca", "C$B$", "cat", "cat\ndog"],
["line\nto be wrapped", "another\nline\nto be wrapped"],
],
)
Expand Down