python
기본 사용(모든 정규식 패턴찾기)
import re
proot = re.compile(정규식패턴,정규식옵션)
mroot = proot.findall(대상문자열소스)
정규식샘플
전체주석
re.DOTALL
<!--.*→>
/[*].*[*]/
주석, 경로문자
re.MULTILINE
regcomment = '[\s\n]//.*'
regpath = '[\'"][cdef][:].*[\'"]'
URL
http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+
검색결과 라인번호 찍기 예제
proot = re.compile(rootcondition,rootoption) for mroot2 in proot.finditer(srcData): start_line = len(re_newline.findall(srcData, 0, mroot2.start()))+1 rootContent = mroot2.group().replace('\t','') #start_line이 라인번호