Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parse IPv6 address in string

Status
Not open for further replies.

dcProgrammer

Programmer
Aug 2, 2012
2
US
Hi,

Maybe a bit of a newbie Python question... I have a dynamic string. Somewhere in that string is an IPv6 address. I need to store that address in a variable. Problem is it's not always in the same location in the string, surrounding text is always different, and from what I understand IPv6 addresses can be written a few different ways. Any quick thoughts?!


-d

 
You say the surrounding text is always different
will teh IP6 address at least be separated by white-space or could you receive something like
addr:2001:db8:85a3::8a2e:370:7334
obviously if there is white-space either side of the address it will be much easier.


A Maintenance contract is essential, not a Luxury.
Do things on the cheap & it will cost you dear
 
Thanks for the input! Unfortunately, the surrounding text is all over the map. There may be brackets in one case, there may be white space in another, or the address may be butted up against other text.

I tried using the regular expression found here: but I couldn't get the syntax correct for Python. Anyone willing to take a stab at making it work in Python?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top