There is no regex() function in base. There is one, however in stringr, maybe that's the one you are using?
❯ base::regex
Error: object 'regex' not found
❯ getAnywhere("regex")
no object named ‘regex’ was found
❯ stringr::regex
function (pattern, ignore_case = FALSE, multiline = FALSE, comments = FALSE,
dotall = FALSE, ...)