My Android-app have always presented the DNS-Server(s) with brackets / leading slashes like:
![](https://i0.wp.com/www.cipv6.de/worp/wp-content/uploads/2021/05/1-2.jpg?resize=417%2C624&ssl=1)
How can we get rid of these unnecessary characters ?
String myIp2Dns1:
String myIp2Dns1 = String.valueOf (LinkProp.getDnsServers()) ;
Log:
Log.d("myDnsInfo - Domain - ", "Domain = " + LinkProp.getDomains());
D/myDnsInfo: dns = [/10.0.2.3]
Solution:
Manipulation of String myIp2Dns1:
myIp2Dns1 = myIp2Dns1.replaceAll("[\\[\\](){}\"^/+\"]","");
This command removes brackets / slashes / backslashes from the String.
The output looks much better now:
![](https://i0.wp.com/www.cipv6.de/worp/wp-content/uploads/2021/05/image.png?resize=345%2C136&ssl=1)
You must be logged in to post a comment.