@@ -822,6 +822,17 @@ def test_match_case_kwarg(any_string_dtype):
822
822
tm .assert_series_equal (result , expected )
823
823
824
824
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
+
825
836
# --------------------------------------------------------------------------------------
826
837
# str.fullmatch
827
838
# --------------------------------------------------------------------------------------
@@ -891,6 +902,17 @@ def test_fullmatch_case_kwarg(any_string_dtype):
891
902
tm .assert_series_equal (result , expected )
892
903
893
904
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
+
894
916
# --------------------------------------------------------------------------------------
895
917
# str.findall
896
918
# --------------------------------------------------------------------------------------
0 commit comments