■ 부정형 전방 탐색하기

----------------------------------------------------------------------------------------------------

import re

 

srePattern = re.compile('.*[.](?!bat$|exe$).*$')

sreMatch = srePattern.search('autoexec.bat\nprogram.exe\ndata.csv')

print(sreMatch.group())

 

[결과]

 

'data.csv'

----------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker
TAG