附leetcode链接:https://leetcode.com/problems/defanging-an-ip-address/
1108. Defanging an IP Address
Given a valid (IPv4)IP address, return a defanged version of that IP address. A defanged IP address replaces every period "." with "[.]".
public String defangIPaddr(String address) {
return address.replace(".","[.]");
}
小结:字符串处理,用到了字符串的api,对字符串的某些子串进行替换:replace(String old,String new)。
参考:https://www.runoob.com/java/java-string-replace.html