0Pricing
NLP Academy · บทเรียน

ค้นหาอีเมลและ URL

ดึงข้อมูลติดต่อจากข้อความที่ยุ่งเหยิง

ค้นหาอีเมลและ URL เป็นบทเรียน NLP Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน NLP Academy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส NLP Academy มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

Patterns Hide in Messy Text

Real text is full of structured snippets like emails and links. Regex lets you pull these out automatically, even from long, messy documents.

What an Email Looks Like

An email has a name, an at sign, a domain, and an extension. Spotting that shape is the first step to writing a pattern for it.

A Simple Email Pattern

This email pattern grabs word characters, an at sign, more characters, a dot, and letters. It is not perfect, but it catches most real addresses.

re.findall("\w+@\w+\.\w+", "hi a@b.com")

Why the Dot Needs Escaping

In a domain you want a literal dot, not the any-character dot. So you escape it as \. to match only a real period in the address.

Extracting Many Emails at Once

Pair your email pattern with re.findall to sweep an entire document and return every address it contains as a clean Python list.

emails = re.findall(pattern, text)

What a URL Looks Like

A URL usually starts with http or https, then ://, then a domain and path. That predictable start makes it a great target for regex.

A Starter URL Pattern

This URL pattern matches http or https, then any non-space characters. The optional s after http is written with a question mark quantifier.

re.findall("https?://\S+", text)

Optional Parts With the Question Mark

The question mark makes the part before it optional. In https? the s may or may not be there, so both http and https match cleanly.

Greedy Matching Can Overreach

By default quantifiers are greedy and grab as much as they can. With URLs this can swallow trailing punctuation you did not want.

Tame It With Boundaries

Use \S to stop at the first space, or trim the result afterward. Knowing where a match should end keeps your extraction tidy.

Test on Real Samples

Always test your pattern on messy real text. Edge cases like plus signs in emails or query strings in URLs reveal where it still leaks.

Quick Check

You want http to be optional in the s only. Which symbol makes the preceding character optional?

Recap: Pulling Out Contact Info

You built patterns for emails and URLs, escaped literal dots, and used the question mark for optional parts. Now you can mine contact info from text. 🔍

คำถามที่พบบ่อย

บทเรียน “ค้นหาอีเมลและ URL” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “ค้นหาอีเมลและ URL” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส NLP Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส NLP Academy มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “ค้นหาอีเมลและ URL”

ดึงข้อมูลติดต่อจากข้อความที่ยุ่งเหยิง คุณปฏิบัติ NLP Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน NLP Academy หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน NLP Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน

บทเรียน “ค้นหาอีเมลและ URL” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน NLP Academy นี้ได้ไหม

ได้ บทเรียน NLP Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. Regex ใน 5 นาที
  2. ค้นหาอีเมลและ URL
  3. กลุ่มจับคู่และการแทนที่
  4. เคล็ดลับการสร้างโทเคนด้วย Regex
← กลับไปที่ NLP Academy