-3

I have several lines that are

192.168.86.3 0x1 0x2 3cbbaxrad * br-lan 192.168.86.213 0x1 0x2 3cccfargarad * br-lan 192.168.86.51 0x1 0x2 3cccfcvrad * br-lan 192.168.86.11 0x1 0x2 3cccfxxrad * br-lan

I need to extract only the ip addresses so it's 192.168.86.3 192.168.86.213 192.168.86.51 192.168.86.11

Can anyone help? Thanks

2 Answers2

0

This works for your test case:

\d*\.\d*\.\d*\.\d*
bhazero025
  • 335
  • 4
  • 15
0

This is a good fit. It only picks up numeric sequences up to three digits and with periods in between. The ()'s make it a selection sequence. So that you can use a replacement string like $1 to only deposit IP addresses.

(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})

Try out this link for more help: https://regex101.com/r/p3NdGL/1

Display name
  • 1,090
  • 1
  • 14
  • 23