๐ป Coding Problems Solving/Hack
[JAVA] ์ ๊ท์์ด๋ ์ถ์ฒ์ผ๋ก ์์๋ณด๋ regex
class Solution { public String solution(String new_id) { String answer = new_id.toLowerCase(); // 1๋จ๊ณ answer = answer.replaceAll("[^-_.a-z0-9]", ""); // 2๋จ๊ณ answer = answer.replaceAll("[.]{2,}", "."); // 3๋จ๊ณ answer = answer.replaceAll("^[.]|[.]$", ""); // 4๋จ๊ณ if (answer.equals("")) { // 5๋จ๊ณ answer += "a"; } if (answer.length() >= 16) { // 6๋จ๊ณ answer = answer.substring(0, 15); answer = answer.rep..
2022. 10. 14. 15:22
์ต๊ทผ๋๊ธ