preg (PS: EREG is deprecated.) does not have the logic built in to handle this in one line without some really awful and long patterns.
Incidentally, your system will fail to pass variables, because & and ? are not in your parsing.
Simple suggestion would be to replace all current links with a temporary value (Something like #http;//theurl# , though you should probably use a more obscure character than that. Note the semicolon instead of the colon), then do your replacement, then undo the temporary values.