"Python 정규표현식"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
 
3번째 줄: 3번째 줄:


==findall==
==findall==
<source lang='python'>
<syntaxhighlight lang='python'>
import re
import re


12번째 줄: 12번째 줄:
     print( mo )
     print( mo )
     # ['hello', 'hello', 'hello', 'hello']
     # ['hello', 'hello', 'hello', 'hello']
</source>
</syntaxhighlight>


==search==
==search==
<source lang='python'>
<syntaxhighlight lang='python'>
import re
import re


26번째 줄: 26번째 줄:
     print( mo.group() )
     print( mo.group() )
     # hello
     # hello
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==

2020년 11월 2일 (월) 02:31 기준 최신판

1 개요[ | ]

Python 정규표현식

2 findall[ | ]

import re

text = "hello 1122 : reference hello, hello 1033: argument hello"
regex = re.compile("hello")
mo = regex.findall(text)
if mo != None:
    print( mo )
    # ['hello', 'hello', 'hello', 'hello']

3 search[ | ]

import re

text = "hello 1122 : reference hello, hello 1033: argument hello"
regex = re.compile("hello")
mo = regex.search(text)
if mo != None:
    print( mo )
    # <_sre.SRE_Match object; span=(0, 5), match='hello'>
    print( mo.group() )
    # hello

4 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}