- Published on
Leetcode 1108 - Defanging an IP Address solution
- Authors
- Name
- Imran Pollob
- Website
- @pollmix
Solution One:
class Solution:
def defangIPaddr(self, address: str) -> str:
return address.replace('.', '[.]')
Solution Two:
Using regex
class Solution {
public String defangIPaddr(String address) {
return address.replaceAll("\\.", "[.]");
}
}