If you want to change the expression to completely or completely remove the empty line or , you will need to use the anchor metacharacters ^ and $ (which correspond to the beginning and end of the line, respectively).
^(|https?:\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+
As shown in the figure, you can simplify your protocol a bit for the protocol, so I have included it for you as well.
Although, if you use this expression from a program or script, it may be easier for you to use languages โโfor your own means of checking for empty input.
// in no particular language...
if input.length > 0 then
if input matches <regex> then
input is a URL
else
input is invalid
else
input is empty