import re
def name_norm(text):
print 'target: ' + text
text = re.sub(r" ?\([^)]+\)", "", text).strip()
print 'step1: ' + text
text = re.sub('[-=+.,#/?*:$!}]', ' ', text).strip()
print 'step2: ' + text
text = ' '.join(text.split()).strip()
print 'step3: ' + text
return text
name_norm("a,b")
name_norm("a (a)")
반응형
'프로그래밍 > python' 카테고리의 다른 글
리스트를 청크 단위로 나누기 (0) | 2021.03.28 |
---|---|
날짜 하루씩 더하기 (0) | 2020.12.17 |
list 에서 맨 뒤의 인덱스를 가져오는 방법. (0) | 2020.12.17 |
python json 파일 읽기 (0) | 2016.01.03 |