How to get the only the partial of text

hi
bellow is a text . but i just need the 2nd half of the ip till :110

ip=192.168.1.22-192.168.1.22:110 adm_status=0 holddown_interval=300
max_connections=0 weight=1 option=01
alive=0 total=1 enable=00000001 alive=00000000 power=0

ip=192.168.1.21-192.168.1.21:990 adm_status=0 holddown_interval=300
max_connections=0 weight=1 option=01
alive=0 total=1 enable=00000001 alive=00000000 power=0

So basically , i just want :192.168.1.22:110 , 192.168.1.21:990

But dont understand how to get that
thanks for the help and showing me some good path to further study
Thanks

How about this?

my_string.scan /-(.+)(?=:)/

Oops, I missed the final part. This one should do it:

my_string.scan /-([^ ]+)/

Looking at OP’s sample output, they want it without the trailing :ddd
(port?), so:

/-(.*?):confused:

will give just the second ip.

N.B.: scan returns each match group as a single element array inside
the array of matches. So doing something like:

input.map {|line| line.scan /-(.*?):confused: }

gives:

[[[“192.168.1.22”]], [[“192.168.1.21”]]]

which might be a lot to unpack. #flatten will fix that up:

input.map {|line| line.scan /-(.*?):confused: }.flatten

=> [“192.168.1.22”, “192.168.1.21”]