IMPORTANT : Due to the \K form, you must click, exclusively, on the Replace All button ( DON’T use the step-by-step replacement, with the Replace button )

NOTES :

This regex will work even if Random text1 and/or Random text2 and/or Random text3 does not exist

This regex will work even if no blank character ( space or tabulation ), exists between the IP address and Random text4, in second line

The part ((?:\d{1,3}\.){3}\d{1,3}) looks for four integers, from 1 to 3 digits, separated by the dot symbol. However, consider that this regex does not verify the integrity of the IP address. Indeed, this syntax would match the string 999.999.999.999, which is not, obviously, a valid IP address !

The IP address, preceded and followed by any range, even null, of characters ( .* ) and ended by its EOL characters ( \R ) is, then, forgotten by the regex engine, due to the \K syntax

Now, it tries to match the second line : any range even null, of characters, followed by the SAME IP address, stored as group 1 ( \1 ), followed by possible horizontal blank characters ( \h* )