Posts: 4,551
Threads: 1,459
Joined: Sep 2016
i am reading in a sequence of lines from a file. each line has zero or more (usually at least one) IPv4 addresses embedded within other text. there may be no space before or after the IPv4 address, but, there is never a decimal digit immediately adjacent to the IPv4 address. is there any code that extract just the IPv4 addresses from such a string and return a list of them (an empty list if there are not any)? else i'll write my own.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,551
Threads: 1,459
Joined: Sep 2016
Aug-30-2019, 08:09 PM
(This post was last modified: Aug-30-2019, 08:09 PM by Skaperen.)
(Aug-30-2019, 07:33 AM)ThomasL Wrote: Maybe have a look here: https://www.regular-expressions.info/ip.html
funny part where it might match some foreign numbers like Arabic ... ١٢٣.١٢٣.١٢٣.١٢٣ (123.123.123.123)
but what does \b do? they don't explain why that is there or make it be a link to a description. if they mean blank space then this is not what i want and i wonder if it can work without them.
there is a system function (with methods in os) that can tell you if a string is a valid IPv4 address (also a way to check for IPv6). my first plan was to call it at every position in a string in all lengths in range(1,16).
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.