code: def test_replace_regex_inplace_refs(
      using_copy_on_write, warn_copy_on_write
  ):
      df = DataFrame({"a": ["aaa", "bbb"]})
      df_orig = df.copy()
      view = df[:]
      arr = get_array(df, "a")
      with tm.assert_cow_warning(warn_copy_on_write):
          df.replace(
              to_replace=r"^a.*$", value="new", inplace=True, regex=True
          )
      if using_copy_on_write:
          assert not np.shares_memory(arr, get_array(df, "a"))
          assert df._mgr._has_no_reference(0)
          tm.assert_frame_equal(view, df_orig)
      else:
          assert np.shares_memory(arr, get_array(df, "a"))
  
imports: import numpy
  import pytest
  from pandas import Categorical, DataFrame, option_context
  import pandas._testing
  from pandas.tests.copy_view.util import get_array
label_desc: Use image node_id 2 for calling a global function with example usage: test_replace_regex_inplace_refs(using_copy_on_write, warn_copy_on_write) without return types