Python Forum
searching for an IP address in a string
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
searching for an IP address in a string
#1
i am wanting to avoid having to write a function to find the Nth IP address in a string of characters

i do have some thought issues about it. when counting IP addresses to get to the Nth address, should i count substrings that "look like" an IP address even if it is invalid? what should "look like" be? 4 decimal numbers separated by 3 single dots? do i let a typo like a double dot be skipped and end up with the wrong address?

my goal is to create a program to sort files by IP address (IPv4-only first, including IPv6 later). maybe there is something to do this. these will be huge (perhaps many GB) log files not suited for reading it all into RAM. if i develop this, i'll more likely convert each IP address to a number and use the existing "sort" command since it designed to handle massive sized files.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020