Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Challenge: Extract Email Addresses | Introduction to Regular Expressions
Python Regular Expressions
セクション 1.  4
single

single

bookChallenge: Extract Email Addresses

メニューを表示するにはスワイプしてください

Use your knowledge of character classes and quantifiers to extract all email addresses from a block of text. Email addresses follow specific patterns, making them ideal candidates for regular expression matching. Your goal is to write a function that scans a given string and returns every email address it finds.

  • Identify the pattern of a typical email address (for example, username@example.com);
  • Use Python's re module to construct a regular expression that matches email addresses;
  • Write a function that returns a list of all email addresses found in the input string.
Note
Note

Quantifiers in regular expressions let you specify how many times a character, character class, or group must occur for a match. This is essential for patterns like email addresses, where parts of the address can repeat or vary in length. For example, in the pattern [a-zA-Z0-9._%+-]+, the + quantifier means "match one or more of the preceding characters." Common quantifiers include * (zero or more), + (one or more), and {n,m} (between n and m times). Using quantifiers helps you build flexible patterns that match a wide range of text formats.

タスク

スワイプしてコーディングを開始

Write a function that scans a text and extracts every email address it contains.

  1. Identify the structure of a typical email address (e.g., name@example.com).
  2. Use Python’s re module to create a regular expression that matches valid email patterns.
  3. Search the input string for all email occurrences.
  4. Return the list of found email addresses in the same order they appear in the text.

解答

Switch to desktop実践的な練習のためにデスクトップに切り替える下記のオプションのいずれかを利用して、現在の場所から続行する
すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 1.  4
single

single

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

some-alt