@@ -822,6 +822,17 @@ def test_match_case_kwarg(any_string_dtype):
822822 tm .assert_series_equal (result , expected )
823823
824824
825+ def test_match_compiled_regex (any_string_dtype ):
826+ # GH#61952
827+ values = Series (["ab" , "AB" , "abc" , "ABC" ], dtype = any_string_dtype )
828+ result = values .str .match (re .compile (r"ab" ), case = False )
829+ expected_dtype = (
830+ np .bool_ if is_object_or_nan_string_dtype (any_string_dtype ) else "boolean"
831+ )
832+ expected = Series ([True , True , True , True ], dtype = expected_dtype )
833+ tm .assert_series_equal (result , expected )
834+
835+
825836# --------------------------------------------------------------------------------------
826837# str.fullmatch
827838# --------------------------------------------------------------------------------------
@@ -891,6 +902,17 @@ def test_fullmatch_case_kwarg(any_string_dtype):
891902 tm .assert_series_equal (result , expected )
892903
893904
905+ def test_fullmatch_compiled_regex (any_string_dtype ):
906+ # GH#61952
907+ values = Series (["ab" , "AB" , "abc" , "ABC" ], dtype = any_string_dtype )
908+ result = values .str .fullmatch (re .compile (r"ab" ), case = False )
909+ expected_dtype = (
910+ np .bool_ if is_object_or_nan_string_dtype (any_string_dtype ) else "boolean"
911+ )
912+ expected = Series ([True , True , False , False ], dtype = expected_dtype )
913+ tm .assert_series_equal (result , expected )
914+
915+
894916# --------------------------------------------------------------------------------------
895917# str.findall
896918# --------------------------------------------------------------------------------------
0 commit comments