Python 풀이
import re
# re.sub('패턴', '바꿀문자열', '문자열', 바꿀횟수)
def solution(new_id):
new_id = new_id.lower() # 1단계
new_id = re.sub('[^a-z0-9-_.]', '', new_id) # 2단계
new_id = re.sub('(([.])\\2{1,})', '.', new_id) # 3단계
new_id = re.sub('^\.|\.$', '', new_id) # 4단계
if len(new_id) == 0: new_id = 'a' # 5단계
new_id = re.sub('\.$', '', new_id[:15]) # 6단계
while len(new_id) < 3: new_id += new_id[-1] # 7단계
return new_id