Hi,
I am having a problem reversing my public IP address that I retrieve from a website. I wrote a script that finds my computer's public IP address and then tries to reverse it so I can use it for other things. The script is as follows:
$IPAddress = (Invoke-WebRequest ifconfig.me/ip).Content # Now lets split the address into its parts by using the dot ('.') $IPAddressParts = $IPAddress.Split('.') $RIPAddress = $IPAddressParts[3] + "." + $IPAddressParts[2] + "." + $IPAddressParts[1] + "." + $IPAddressParts[0] "This is reversed $RIPAddress"
The problem is that the output it gives me is this:
This is reversed 143.88.151.81
There seems to be a line break after 143. and I don't know why. If I put the IP address manually as a string "81.151.88.143" without using the website, everything works fine.
When if I print the IP right after the website resolves it, it also looks fine and there are no line breaks or anything. As you can see, it reverses it just fine and the problem is only with 143. This happens with any website I have used for retrieving my IP.
The line break seems to be added by the reversing process but it only happens when the IP is parsed from any website.
It seems to be related to sanitising the HTML part to plain text. I have tried parsing to string but I get more of the same. There doesn't seem to be any HTML code contained in the variable after fetching the IP. Can anyone help me with this?