Network disconnection
Description
\d
는 숫자를 한글자만 찾습니다. 그런데, 전화번호를 구성하는 043이나 2568같이 연결된 숫자를 찾고 싶을 때는 어떻게 해야 할까요?
그럴 땐 +
를 이용하면 됩니다. +
는 "하나 혹은 그 이상 연결된"이라는 뜻입니다. 따라서 \d+
는 "하나 혹은 그 이상 연결된 숫자"를 의미합니다.
빈칸에 \d+
를 입력하고 [실행]해 보세요. Output으로 search_target에 들은 모든 연결된 숫자가 한 줄씩 나올 겁니다.
Fill type challenge HOWTO
- In the Fill type challenge, you have to fill the blank with appropriate code
- The given code except the blank cannot be edited.
- An error message will be shown in the Result area when you leave the blank empty.
1
2
3
4
5
6
7
8
9
10
11
# 빈칸에 정규표현식을 적습니다.
regex = r''
search_target = '''Luke Skywarker 02-123-4567 luke@daum.net
다스베이더 070-9999-9999 darth_vader@gmail.com
princess leia 010 2454 3457 leia@gmail.com'''
#아래 부분은 본 강의에서 다루지 않습니다.
import re
result=re.findall(regex,search_target)
print(result)
Result
Stop
Result of [Run] or [Submit] will be displayed here