     assert Regex.replace(~r(b), "abcbe", "d") == "adcde"
     assert Regex.replace(~r(b), "abcbe", "d", global: false) == "adcbe"
 
-    assert Regex.replace(~r/ /, "first third", "\\second\\") ==
-           "first\\second\\third"
-    assert Regex.replace(~r/ /, "first third", "\\\\second\\\\") ==
-           "first\\second\\third"
+    assert Regex.replace(~r/ /, "first third", "\\second\\") == "first\\second\\third"
+    assert Regex.replace(~r/ /, "first third", "\\\\second\\\\") == "first\\second\\third"
 
     assert Regex.replace(~r[a(b)c], "abcabc", fn -> "ac" end) == "acac"
     assert Regex.replace(~r[a(b)c], "abcabc", fn "abc" -> "ac" end) == "acac"

  test "literal source" do
    assert Regex.source(Regex.compile!("foo")) == "foo"
    assert Regex.source(~r"foo") == "foo"
    assert Regex.re_pattern(Regex.compile!("foo"))
           == Regex.re_pattern(~r"foo")

    assert Regex.source(Regex.compile!("\a\b\d\e\f\n\r\s\t\v")) == "\a\b\d\e\f\n\r\s\t\v"
    assert Regex.source(~r<\a\b\d\e\f\n\r\s\t\v>) == "\a\\b\\d\\e\f\n\r\\s\t\v"
    assert Regex.re_pattern(Regex.compile!("\a\b\d\e\f\n\r\s\t\v"))
           == Regex.re_pattern(~r"\a\010\177\033\f\n\r \t\v")

    assert Regex.source(Regex.compile!("\a\\b\\d\e\f\n\r\\s\t\v")) == "\a\\b\\d\e\f\n\r\\s\t\v"
    assert Regex.source(~r<\a\\b\\d\\e\f\n\r\\s\t\v>) == "\a\\\\b\\\\d\\\\e\f\n\r\\\\s\t\v"
    assert Regex.re_pattern(Regex.compile!("\a\\b\\d\e\f\n\r\\s\t\v"))
           == Regex.re_pattern(~r"\a\b\d\e\f\n\r\s\t\v")
  end

  test "Unicode" do

    assert Regex.match?(~r/foo/i, "FOO")
    assert Regex.match?(~r/\d{1,3}/i, "123")

    assert Regex.match?(~r/foo/, "afooa")
    refute Regex.match?(~r/^foo/, "afooa")
    assert Regex.match?(~r/^foo/, "fooa")
    refute Regex.match?(~r/foo$/, "afooa")
    assert Regex.match?(~r/foo$/, "afoo")
  end

  test "named_captures/2" do
