Regex works in regexr, but not if I filter content [closed]

Per comments, it’s best to use single quoted strings for regexs in PHP (then only backslash and single quote are special), and only backslash as necessary, eg in this case

$url_regex = '/href="https://wordpress.stackexchange.com/questions/219419/(http"https):\/\/.+?"https://wordpress.stackexchange.com/";

(leaving out the positive lookahead which isn’t needed here).