알고리즘/프로그래머스

프로그래머스 [코딩테스트 입문 100] 문자열 정렬하기(1) (Python)

울우리우리 2022. 11. 16. 22:29

re.sub 매서드를 사용하여 모든 소문자 대문자를 ''(빈칸)으로 치환. 
나머지 숫자들을 오름차순으로 정렬하여 리턴

import re
def solution(my_string):
    my_str = list(map(int, re.sub(r"[{a-z}{A-Z}]", "", my_string)))
    answer = sorted(my_str)
    return answer