Python re.findall() 사용법: 모든 일치하는 부분 문자열 찾기

PythonBeginner
지금 연습하기

소개

이 튜토리얼에서는 텍스트에서 일치하는 부분 문자열을 추출하는 강력한 도구인 Python 의 re.findall() 함수를 살펴보겠습니다. 이 함수는 Python 의 내장 정규 표현식 (regex) 모듈의 일부이며 텍스트 처리 작업에 필수적입니다.

이 Lab 을 마치면 re.findall()을 사용하여 이메일 주소, 전화 번호, URL 등 텍스트에서 다양한 패턴을 추출할 수 있게 됩니다. 이러한 기술은 데이터 분석, 웹 스크래핑 (web scraping), 텍스트 처리 응용 프로그램에서 유용합니다.

Python 을 처음 접하거나 텍스트 처리 능력을 향상시키려는 경우, 이 단계별 가이드는 Python 프로젝트에서 정규 표현식을 효과적으로 사용하는 데 필요한 실용적인 지식을 제공할 것입니다.

re.findall() 시작하기

이 첫 번째 단계에서는 re.findall() 함수와 기본 패턴 매칭에 사용하는 방법을 배우겠습니다.

정규 표현식 이해하기

정규 표현식 (regex) 은 검색 패턴을 설명하는 데 사용되는 특수 텍스트 문자열입니다. 다음과 같은 경우에 특히 유용합니다.

  • 텍스트에서 특정 문자 패턴 찾기
  • 텍스트 형식 유효성 검사 (예: 이메일 주소)
  • 텍스트에서 정보 추출
  • 텍스트 대체

Python 의 re 모듈

Python 은 정규 표현식 작업을 위한 re라는 내장 모듈을 제공합니다. 이 모듈의 가장 유용한 함수 중 하나는 re.findall()입니다.

re.findall()이 어떻게 작동하는지 확인하기 위해 간단한 Python 스크립트를 만들어 보겠습니다.

  1. 먼저 터미널을 열고 프로젝트 디렉토리로 이동합니다.
cd ~/project
  1. 코드 편집기를 사용하여 basic_findall.py라는 새 Python 파일을 만듭니다. VSCode 에서 "Explorer" 아이콘 (일반적으로 사이드바의 첫 번째 아이콘) 을 클릭한 다음 "New File" 버튼을 클릭하고 이름을 basic_findall.py로 지정할 수 있습니다.

  2. basic_findall.py 파일에 다음 코드를 작성합니다.

import re

## Sample text
text = "Python is amazing. Python is versatile. I love learning Python programming."

## Using re.findall() to find all occurrences of "Python"
matches = re.findall(r"Python", text)

## Print the results
print("Original text:")
print(text)
print("\nMatches found:", len(matches))
print("Matching substrings:", matches)
  1. 파일을 저장하고 터미널에서 실행합니다.
python3 ~/project/basic_findall.py

다음과 유사한 출력을 볼 수 있습니다.

Original text:
Python is amazing. Python is versatile. I love learning Python programming.

Matches found: 3
Matching substrings: ['Python', 'Python', 'Python']

코드 분석

코드에서 무슨 일이 일어나는지 이해해 보겠습니다.

  • import re를 사용하여 re 모듈을 가져왔습니다.
  • "Python"이라는 단어가 여러 번 나타나는 샘플 텍스트를 정의했습니다.
  • re.findall(r"Python", text)를 사용하여 텍스트에서 "Python"의 모든 발생을 찾았습니다.
  • 문자열 앞의 r은 정규 표현식 작업 시 권장되는 raw 문자열을 나타냅니다.
  • 함수는 일치하는 모든 부분 문자열의 목록을 반환했습니다.
  • 결과를 출력하여 텍스트에서 "Python"이 3 번 나타났음을 보여주었습니다.

다른 패턴 찾기

이제 다른 패턴을 찾아보겠습니다. findall_words.py라는 새 파일을 만듭니다.

import re

text = "The rain in Spain falls mainly on the plain."

## Find all words ending with 'ain'
matches = re.findall(r"\w+ain\b", text)

print("Original text:")
print(text)
print("\nWords ending with 'ain':", matches)

이 스크립트를 실행합니다.

python3 ~/project/findall_words.py

출력은 다음과 같아야 합니다.

Original text:
The rain in Spain falls mainly on the plain.

Words ending with 'ain': ['rain', 'Spain', 'plain']

이 예에서:

  • \w+는 하나 이상의 단어 문자 (문자, 숫자 또는 밑줄) 와 일치합니다.
  • ain은 리터럴 문자 "ain"과 일치합니다.
  • \b는 단어 경계를 나타내어 "ain"으로 끝나는 완전한 단어와 일치하도록 합니다.

re.findall()이 기본 패턴으로 어떻게 작동하는지 파악하려면 이러한 예제를 사용해 보십시오.

더 복잡한 패턴으로 작업하기

이 단계에서는 re.findall()을 사용하여 더 복잡한 패턴을 살펴보고 문자 클래스와 수량자를 사용하여 유연한 검색 패턴을 만드는 방법을 배우겠습니다.

텍스트에서 숫자 찾기

먼저 텍스트에서 모든 숫자를 추출하는 스크립트를 작성해 보겠습니다. extract_numbers.py라는 새 파일을 만듭니다.

import re

text = "There are 42 apples, 15 oranges, and 123 bananas in the basket. The price is $9.99."

## Find all numbers (integers and decimals)
numbers = re.findall(r'\d+\.?\d*', text)

print("Original text:")
print(text)
print("\nNumbers found:", numbers)

## Finding only whole numbers
whole_numbers = re.findall(r'\b\d+\b', text)
print("Whole numbers only:", whole_numbers)

스크립트를 실행합니다.

python3 ~/project/extract_numbers.py

다음과 유사한 출력을 볼 수 있습니다.

Original text:
There are 42 apples, 15 oranges, and 123 bananas in the basket. The price is $9.99.

Numbers found: ['42', '15', '123', '9.99']
Whole numbers only: ['42', '15', '123', '9']

사용된 패턴을 분석해 보겠습니다.

  • \d+\.?\d*는 다음 항목과 일치합니다.

    • \d+: 하나 이상의 숫자
    • \.?: 선택적 소수점
    • \d*: 소수점 뒤의 0 개 이상의 숫자
  • \b\d+\b는 다음 항목과 일치합니다.

    • \b: 단어 경계
    • \d+: 하나 이상의 숫자
    • \b: 또 다른 단어 경계 (독립형 숫자와 일치하도록 보장)

특정 길이의 단어 찾기

텍스트에서 모든 4 글자 단어를 찾는 스크립트를 만들어 보겠습니다. find_word_length.py를 만듭니다.

import re

text = "The quick brown fox jumps over the lazy dog. A good day to code."

## Find all 4-letter words
four_letter_words = re.findall(r'\b\w{4}\b', text)

print("Original text:")
print(text)
print("\nFour-letter words:", four_letter_words)

## Find all words between 3 and 5 letters
words_3_to_5 = re.findall(r'\b\w{3,5}\b', text)
print("Words with 3 to 5 letters:", words_3_to_5)

이 스크립트를 실행합니다.

python3 ~/project/find_word_length.py

출력은 다음과 같아야 합니다.

Original text:
The quick brown fox jumps over the lazy dog. A good day to code.

Four-letter words: ['over', 'lazy', 'good', 'code']
Words with 3 to 5 letters: ['The', 'over', 'the', 'lazy', 'dog', 'good', 'day', 'code']

이러한 패턴에서:

  • \b\w{4}\b는 단어 경계로 둘러싸인 정확히 4 개의 단어 문자와 일치합니다.
  • \b\w{3,5}\b는 단어 경계로 둘러싸인 3~5 개의 단어 문자와 일치합니다.

문자 클래스 사용

문자 클래스를 사용하면 특정 문자 집합과 일치시킬 수 있습니다. character_classes.py를 만들어 보겠습니다.

import re

text = "The temperature is 72°F or 22°C. Contact us at: info@example.com"

## Find words containing both letters and digits
mixed_words = re.findall(r'\b[a-z0-9]+\b', text.lower())

print("Original text:")
print(text)
print("\nWords with letters and digits:", mixed_words)

## Find all email addresses
emails = re.findall(r'\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}\b', text)
print("Email addresses:", emails)

스크립트를 실행합니다.

python3 ~/project/character_classes.py

출력은 다음과 유사해야 합니다.

Original text:
The temperature is 72°F or 22°C. Contact us at: info@example.com

Words with letters and digits: ['72°f', '22°c', 'info@example.com']
Email addresses: ['info@example.com']

이러한 패턴은 다음을 보여줍니다.

  • \b[a-z0-9]+\b: 소문자와 숫자를 모두 포함하는 단어
  • 이메일 패턴은 이메일 주소의 표준 형식과 일치합니다.

다양한 패턴 구성 요소가 함께 작동하여 강력한 검색 패턴을 만드는 방법을 이해하려면 이러한 예제를 사용해 보십시오.

플래그 및 캡처 그룹 사용하기

이 단계에서는 플래그를 사용하여 정규 표현식의 동작을 수정하는 방법과 캡처 그룹을 사용하여 일치하는 패턴의 특정 부분을 추출하는 방법을 배우겠습니다.

정규 표현식의 플래그 이해하기

플래그는 정규 표현식 엔진이 검색을 수행하는 방식을 수정합니다. Python 의 re 모듈은 re.findall()에 선택적 매개변수로 전달할 수 있는 여러 플래그를 제공합니다. 몇 가지 일반적인 플래그를 살펴보겠습니다.

regex_flags.py라는 새 파일을 만듭니다.

import re

text = """
Python is a great language.
PYTHON is versatile.
python is easy to learn.
"""

## Case-sensitive search (default)
matches_case_sensitive = re.findall(r"python", text)

## Case-insensitive search using re.IGNORECASE flag
matches_case_insensitive = re.findall(r"python", text, re.IGNORECASE)

print("Original text:")
print(text)
print("\nCase-sensitive matches:", matches_case_sensitive)
print("Case-insensitive matches:", matches_case_insensitive)

## Using the multiline flag
multiline_text = "First line\nSecond line\nThird line"
## Find lines starting with 'S'
starts_with_s = re.findall(r"^S.*", multiline_text, re.MULTILINE)
print("\nMultiline text:")
print(multiline_text)
print("\nLines starting with 'S':", starts_with_s)

스크립트를 실행합니다.

python3 ~/project/regex_flags.py

출력은 다음과 유사해야 합니다.

Original text:

Python is a great language.
PYTHON is versatile.
python is easy to learn.


Case-sensitive matches: ['python']
Case-insensitive matches: ['Python', 'PYTHON', 'python']

Multiline text:
First line
Second line
Third line

Lines starting with 'S': ['Second line']

일반적인 플래그는 다음과 같습니다.

  • re.IGNORECASE (또는 re.I): 패턴을 대소문자를 구분하지 않도록 합니다.
  • re.MULTILINE (또는 re.M): ^$가 각 줄의 시작/끝과 일치하도록 합니다.
  • re.DOTALL (또는 re.S): .이 줄 바꿈 문자를 포함한 모든 문자와 일치하도록 합니다.

캡처 그룹 사용하기

캡처 그룹을 사용하면 일치하는 텍스트의 특정 부분을 추출할 수 있습니다. 정규 표현식의 일부를 괄호 안에 넣어서 생성됩니다.

capturing_groups.py라는 파일을 만듭니다.

import re

## Sample text with dates in various formats
text = "Important dates: 2023-11-15, 12/25/2023, and Jan 1, 2024."

## Extract dates in YYYY-MM-DD format
iso_dates = re.findall(r'(\d{4})-(\d{1,2})-(\d{1,2})', text)

## Extract dates in MM/DD/YYYY format
us_dates = re.findall(r'(\d{1,2})/(\d{1,2})/(\d{4})', text)

print("Original text:")
print(text)
print("\nISO dates (Year, Month, Day):", iso_dates)
print("US dates (Month, Day, Year):", us_dates)

## Extract month names with capturing groups
month_dates = re.findall(r'(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+(\d{1,2}),\s+(\d{4})', text)
print("Month name dates (Month, Day, Year):", month_dates)

스크립트를 실행합니다.

python3 ~/project/capturing_groups.py

출력은 다음과 같아야 합니다.

Original text:
Important dates: 2023-11-15, 12/25/2023, and Jan 1, 2024.

ISO dates (Year, Month, Day): [('2023', '11', '15')]
US dates (Month, Day, Year): [('12', '25', '2023')]
Month name dates (Month, Day, Year): [('Jan', '1', '2024')]

이 예에서:

  • 각 괄호 세트 ()는 캡처 그룹을 생성합니다.
  • 함수는 튜플 목록을 반환하며, 각 튜플에는 캡처된 그룹이 포함되어 있습니다.
  • 이를 통해 텍스트에서 구조화된 데이터를 추출하고 구성할 수 있습니다.

실용적인 예: 로그 파일 구문 분석

이제 배운 내용을 실용적인 예에 적용해 보겠습니다. 구문 분석하려는 항목이 있는 로그 파일이 있다고 가정해 보겠습니다. log_parser.py라는 파일을 만듭니다.

import re

## Sample log entries
logs = """
[2023-11-15 08:30:45] INFO: System started
[2023-11-15 08:35:12] WARNING: High memory usage (85%)
[2023-11-15 08:42:11] ERROR: Connection timeout
[2023-11-15 09:15:27] INFO: Backup completed
"""

## Extract timestamp, level, and message from log entries
log_pattern = r'\[(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})\] (\w+): (.+)'
log_entries = re.findall(log_pattern, logs)

print("Original logs:")
print(logs)
print("\nParsed log entries (timestamp, level, message):")
for entry in log_entries:
    timestamp, level, message = entry
    print(f"Time: {timestamp} | Level: {level} | Message: {message}")

## Find all ERROR logs
error_logs = re.findall(r'\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\] ERROR: (.+)', logs)
print("\nError messages:", error_logs)

스크립트를 실행합니다.

python3 ~/project/log_parser.py

출력은 다음과 유사해야 합니다.

Original logs:

[2023-11-15 08:30:45] INFO: System started
[2023-11-15 08:35:12] WARNING: High memory usage (85%)
[2023-11-15 08:42:11] ERROR: Connection timeout
[2023-11-15 09:15:27] INFO: Backup completed


Parsed log entries (timestamp, level, message):
Time: 2023-11-15 08:30:45 | Level: INFO | Message: System started
Time: 2023-11-15 08:35:12 | Level: WARNING | Message: High memory usage (85%)
Time: 2023-11-15 08:42:11 | Level: ERROR | Message: Connection timeout
Time: 2023-11-15 09:15:27 | Level: INFO | Message: Backup completed

Error messages: ['Connection timeout']

이 예는 다음을 보여줍니다.

  • 캡처 그룹을 사용하여 구조화된 정보 추출
  • 캡처된 정보 처리 및 표시
  • 특정 유형의 로그 항목 필터링

플래그와 캡처 그룹은 정규 표현식의 강력함과 유연성을 향상시켜 보다 정확하고 구조화된 데이터 추출을 가능하게 합니다.

re.findall() 의 실제 사용 사례

이 마지막 단계에서는 re.findall()의 실용적이고 실제적인 사용 사례를 살펴보겠습니다. 이메일, URL 을 추출하고 데이터 정리 작업을 수행하는 코드를 작성합니다.

이메일 주소 추출

이메일 추출은 데이터 마이닝, 웹 스크래핑 (web scraping), 텍스트 분석에서 일반적인 작업입니다. email_extractor.py라는 파일을 만듭니다.

import re

## Sample text with email addresses
text = """
Contact information:
- Support: support@example.com
- Sales: sales@example.com, international.sales@example.co.uk
- Technical team: tech.team@subdomain.example.org
Personal email: john.doe123@gmail.com
"""

## Extract all email addresses
email_pattern = r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b'
emails = re.findall(email_pattern, text)

print("Original text:")
print(text)
print("\nExtracted email addresses:")
for i, email in enumerate(emails, 1):
    print(f"{i}. {email}")

## Extract specific domain emails
gmail_emails = re.findall(r'\b[A-Za-z0-9._%+-]+@gmail\.com\b', text)
print("\nGmail addresses:", gmail_emails)

스크립트를 실행합니다.

python3 ~/project/email_extractor.py

출력은 다음과 유사해야 합니다.

Original text:

Contact information:
- Support: support@example.com
- Sales: sales@example.com, international.sales@example.co.uk
- Technical team: tech.team@subdomain.example.org
Personal email: john.doe123@gmail.com


Extracted email addresses:
1. support@example.com
2. sales@example.com
3. international.sales@example.co.uk
4. tech.team@subdomain.example.org
5. john.doe123@gmail.com

Gmail addresses: ['john.doe123@gmail.com']

URL 추출

URL 추출은 웹 스크래핑, 링크 유효성 검사 및 콘텐츠 분석에 유용합니다. url_extractor.py라는 파일을 만듭니다.

import re

## Sample text with various URLs
text = """
Visit our website at https://www.example.com
Documentation: http://docs.example.org/guide
Repository: https://github.com/user/project
Forum: https://community.example.net/forum
Image: https://images.example.com/logo.png
"""

## Extract all URLs
url_pattern = r'https?://[^\s]+'
urls = re.findall(url_pattern, text)

print("Original text:")
print(text)
print("\nExtracted URLs:")
for i, url in enumerate(urls, 1):
    print(f"{i}. {url}")

## Extract specific domain URLs
github_urls = re.findall(r'https?://github\.com/[^\s]+', text)
print("\nGitHub URLs:", github_urls)

## Extract image URLs
image_urls = re.findall(r'https?://[^\s]+\.(jpg|jpeg|png|gif)', text)
print("\nImage URLs:", image_urls)

스크립트를 실행합니다.

python3 ~/project/url_extractor.py

출력은 다음과 유사해야 합니다.

Original text:

Visit our website at https://www.example.com
Documentation: http://docs.example.org/guide
Repository: https://github.com/user/project
Forum: https://community.example.net/forum
Image: https://images.example.com/logo.png


Extracted URLs:
1. https://www.example.com
2. http://docs.example.org/guide
3. https://github.com/user/project
4. https://community.example.net/forum
5. https://images.example.com/logo.png

GitHub URLs: ['https://github.com/user/project']

Image URLs: ['https://images.example.com/logo.png']

re.findall() 을 사용한 데이터 정리

지저분한 데이터 세트에서 정보를 정리하고 추출하는 스크립트를 만들어 보겠습니다. data_cleaning.py라는 파일을 만듭니다.

import re

## Sample messy data
data = """
Product: Laptop X200, Price: $899.99, SKU: LP-X200-2023
Product: Smartphone S10+, Price: $699.50, SKU: SP-S10P-2023
Product: Tablet T7, Price: $299.99, SKU: TB-T7-2023
Product: Wireless Earbuds, Price: $129.95, SKU: WE-PRO-2023
"""

## Extract product information
product_pattern = r'Product: (.*?), Price: \$([\d.]+), SKU: ([A-Z0-9-]+)'
products = re.findall(product_pattern, data)

print("Original data:")
print(data)
print("\nExtracted and structured product information:")
print("Name\t\tPrice\t\tSKU")
print("-" * 50)
for product in products:
    name, price, sku = product
    print(f"{name}\t${price}\t{sku}")

## Calculate total price
total_price = sum(float(price) for _, price, _ in products)
print(f"\nTotal price of all products: ${total_price:.2f}")

## Extract only products above $500
expensive_products = [name for name, price, _ in products if float(price) > 500]
print("\nExpensive products (>$500):", expensive_products)

스크립트를 실행합니다.

python3 ~/project/data_cleaning.py

출력은 다음과 유사해야 합니다.

Original data:

Product: Laptop X200, Price: $899.99, SKU: LP-X200-2023
Product: Smartphone S10+, Price: $699.50, SKU: SP-S10P-2023
Product: Tablet T7, Price: $299.99, SKU: TB-T7-2023
Product: Wireless Earbuds, Price: $129.95, SKU: WE-PRO-2023


Extracted and structured product information:
Name		Price		SKU
--------------------------------------------------
Laptop X200	$899.99	LP-X200-2023
Smartphone S10+	$699.50	SP-S10P-2023
Tablet T7	$299.99	TB-T7-2023
Wireless Earbuds	$129.95	WE-PRO-2023

Total price of all products: $2029.43

Expensive products (>$500): ['Laptop X200', 'Smartphone S10+']

re.findall() 을 다른 문자열 함수와 결합하기

마지막으로, 고급 텍스트 처리를 위해 re.findall()을 다른 문자열 함수와 결합하는 방법을 살펴보겠습니다. combined_processing.py라는 파일을 만듭니다.

import re

## Sample text with mixed content
text = """
Temperature readings:
- New York: 72°F (22.2°C)
- London: 59°F (15.0°C)
- Tokyo: 80°F (26.7°C)
- Sydney: 68°F (20.0°C)
"""

## Extract all temperature readings in Fahrenheit
fahrenheit_pattern = r'(\d+)°F'
fahrenheit_temps = re.findall(fahrenheit_pattern, text)

## Convert to integers
fahrenheit_temps = [int(temp) for temp in fahrenheit_temps]

print("Original text:")
print(text)
print("\nFahrenheit temperatures:", fahrenheit_temps)

## Calculate average temperature
avg_temp = sum(fahrenheit_temps) / len(fahrenheit_temps)
print(f"Average temperature: {avg_temp:.1f}°F")

## Extract city and temperature pairs
city_temp_pattern = r'- ([A-Za-z\s]+): (\d+)°F'
city_temps = re.findall(city_temp_pattern, text)

print("\nCity and temperature pairs:")
for city, temp in city_temps:
    print(f"{city}: {temp}°F")

## Find the hottest and coldest cities
hottest_city = max(city_temps, key=lambda x: int(x[1]))
coldest_city = min(city_temps, key=lambda x: int(x[1]))

print(f"\nHottest city: {hottest_city[0]} ({hottest_city[1]}°F)")
print(f"Coldest city: {coldest_city[0]} ({coldest_city[1]}°F)")

스크립트를 실행합니다.

python3 ~/project/combined_processing.py

출력은 다음과 유사해야 합니다.

Original text:

Temperature readings:
- New York: 72°F (22.2°C)
- London: 59°F (15.0°C)
- Tokyo: 80°F (26.7°C)
- Sydney: 68°F (20.0°C)


Fahrenheit temperatures: [72, 59, 80, 68]
Average temperature: 69.8°F

City and temperature pairs:
New York: 72°F
London: 59°F
Tokyo: 80°F
Sydney: 68°F

Hottest city: Tokyo (80°F)
Coldest city: London (59°F)

이러한 예는 re.findall()을 다른 Python 기능과 결합하여 실제 텍스트 처리 문제를 해결하는 방법을 보여줍니다. 구조화되지 않은 텍스트에서 구조화된 데이터를 추출하는 능력은 데이터 분석, 웹 스크래핑 및 기타 많은 프로그래밍 작업에 필수적인 기술입니다.

요약

이 튜토리얼에서는 텍스트 패턴 매칭 (text pattern matching) 및 추출을 위해 Python 에서 강력한 re.findall() 함수를 사용하는 방법을 배웠습니다. 다음과 같은 몇 가지 주요 영역에서 실용적인 지식을 얻었습니다.

  1. 기본 패턴 매칭 (Basic Pattern Matching) - 간단한 부분 문자열을 찾는 방법과 특정 텍스트 패턴과 일치하는 기본 정규 표현식 패턴을 사용하는 방법을 배웠습니다.

  2. 복잡한 패턴 (Complex Patterns) - 문자 클래스, 단어 경계 및 수량자를 포함하여 보다 복잡한 패턴을 탐색하여 유연한 검색 패턴을 만들었습니다.

  3. 플래그 및 캡처 그룹 (Flags and Capturing Groups) - re.IGNORECASE와 같은 플래그를 사용하여 검색 동작을 수정하는 방법과 캡처 그룹을 사용하여 구조화된 데이터를 추출하는 방법을 배웠습니다.

  4. 실제 사용 사례 (Real-world Applications) - 이메일 주소 및 URL 추출, 로그 파일 구문 분석, 데이터 정리와 같은 실제 시나리오에 지식을 적용했습니다.

이 랩에서 개발한 기술은 다음과 같은 광범위한 텍스트 처리 작업에 유용합니다.

  • 데이터 추출 및 정리
  • 콘텐츠 분석
  • 웹 스크래핑 (web scraping)
  • 로그 파일 구문 분석
  • 데이터 유효성 검사

정규 표현식과 re.findall() 함수를 사용하면 Python 프로젝트에서 텍스트 데이터를 처리하기 위한 강력한 도구를 갖게 됩니다. 이러한 기술을 계속 연습하고 적용하면 특정 텍스트 처리 요구 사항에 맞는 효율적인 패턴을 만드는 데 더욱 능숙해질 것입니다.