You can use something like this (edited for XE2 TPerlRegEx compatibility):
var
Regex: TPerlRegEx;
ResultString: string;
begin
Regex := TPerlRegEx.Create;
try
Regex.RegEx := '\b((?:[0-9]{1,3}\.){3}[0-9]{1,3})\s(.*)';
Regex.Options := [];
Regex.State := [preNotEmpty];
Regex.Subject := SubjectString;
Regex.Replacement := '\1:\2';
Regex.ReplaceAll;
ResultString := Regex.Subject;
finally
Regex.Free;
end;
end;
Tested with the following values:
85.39.138.58 151
187.39.55.23 399
80.14.5.209 1424
80.14.6.217 1424
1.1.135.73 1464
80.14.5.209 135
80.14.7.2 1392
187.39.55.100 399
67.78.18.222 1472
Results:
85.39.138.58:151
187.39.55.23:399
80.14.5.209:1424
80.14.6.217:1424
1.1.135.73:1464
80.14.5.209:135
80.14.7.2:1392
187.39.55.100:399
67.78.18.222:1472