문자열
-
[문자열/Regex] 문자열 특정 문자 바꾸기Data Science/데이터마이닝 2021. 5. 17. 20:13
문자열에서 특정 문자 바꾸기를 알아봅니다. 오늘의 포스팅에서는 아래와 같은 문자열을 통해 진행해보겠습니다. sample = "My phone number is 010-0000-0000" 1. Replace #기본 문법 => replace(원본값,변경값,변경횟수) result1 = sample.replace('0','9') # 변경횟수는 기본값 all result2 = sample.replace('0','9',1) result3 = sample.replace('0','9',3) My phone number is 919-9999-9999 My phone number is 910-0000-0000 My phone number is 919-9000-0000 2. re.sub #기본 문법 => re.sub(원본값..