정규표현식 - 사용방법(컴파일)
컴파일 후 매칭 import re text = 'hi my name is xxx' p = re.compile('[a-z]') print(re.findall(p, text)) # ['h', 'i', 'm', 'y', 'n', 'a', 'm', 'e', 'i', 's', 'x', 'x', 'x'] 패턴 객체 p 생성 후 매칭 (재사용 가능) 2. 축약 import re text = 'hi my name is xxx' print(re.findall('[a-z]', text)) # ['h', 'i', 'm', 'y', 'n', 'a', 'm', 'e', 'i', 's', 'x', 'x', 'x']
2021. 2. 23.