콘솔워크

문자열에서 대괄호와 대괄호 안의 문자 제거 본문

프로그래밍/python

문자열에서 대괄호와 대괄호 안의 문자 제거

이휘재123 2023. 3. 10. 14:22
반응형
import re

text = "Hello [world], [123] Python [is] awesome."
new_text = re.sub(r'\[.*?\]', '', text)

print(new_text)
# 출력: Hello  Python  awesome.

 

반응형