Monu Tools

ทดสอบ Regex

ทดสอบ regular expression กับข้อความของคุณแบบเรียลไทม์ ดูการจับคู่ทุกรายการที่ไฮไลต์ พร้อม capture groups และ flags ทำงานทั้งหมดในเบราว์เซอร์ของคุณ

วิธีใช้ Regex Tester

  1. 01

    พิมพ์ regular expression ของคุณในช่อง pattern

  2. 02

    สลับ flags (g, i, m, s, u) ที่คุณต้องการ

  3. 03

    ป้อนสตริงทดสอบและดูการจับคู่ที่ไฮไลต์พร้อม groups

What the regex tester does

The regex tester lets you build and debug regular expressions against your own sample text, with matches highlighted live as you type. It is useful for validating input formats, extracting fields from logs, or testing a pattern before pasting it into code.

Everything runs in your browser, so your patterns and test text are never uploaded.

Which engine it uses

It uses the JavaScript regular-expression engine, the same one in every browser and in Node.js, so a pattern that works here works in your JavaScript and TypeScript code.

Flags and capture groups

Toggle the global, case-insensitive, multiline and other flags to change how a pattern matches. You see every match along with its capture groups, so you can confirm exactly what each part of the pattern is pulling out.

Differences across regex flavors

Other languages such as PCRE, Python and Go share most syntax but differ in some features, so a few advanced constructs may behave differently outside JavaScript. If a pattern works here but not in another language, an engine-specific construct is usually the reason.

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

ใช้ regex รสชาติใด?

เครื่องยนต์ JavaScript (ECMAScript) ในเบราว์เซอร์ของคุณ ดังนั้นผลลัพธ์จะตรงกับสิ่งที่โค้ด JavaScript และ TypeScript ของคุณทำ

flags หมายความว่าอะไร?

g จับคู่ทุกครั้งที่เกิดขึ้น, i ละเว้นตัวพิมพ์, m ทำให้ ^ และ $ จับคู่ที่การขึ้นบรรทัดใหม่, s ทำให้จุดจับคู่ newlines และ u เปิดใช้งานการจัดการ Unicode แบบเต็ม

จับคู่ข้ามหลายบรรทัดอย่างไร?

เปิดใช้งาน flag multiline (m) เพื่อให้ ^ และ $ จับคู่ที่การขึ้นบรรทัดใหม่แต่ละครั้ง และเพิ่ม flag dotAll (s) หากคุณต้องการให้จุดจับคู่อักขระ newline ด้วย

แสดง capture groups ไหม?

ใช่ แต่ละการจับคู่แสดง capture groups ที่มีหมายเลข และ named groups จะแสดงตามชื่อ ดังนั้นคุณจะเห็นว่าแต่ละส่วนของ pattern จับอะไร

ทำไม pattern ของฉันใช้งานได้ที่นี่แต่ไม่ได้ในภาษาอื่น?

เครื่องมือนี้ใช้เครื่องยนต์ JavaScript PCRE Python และอื่นๆ มีไวยากรณ์ส่วนใหญ่เหมือนกันแต่แตกต่างกันใน lookbehind, named groups และ escapes บางส่วน ดังนั้นพอร์ต patterns ขั้นสูงด้วยความระมัดระวัง

ข้อความของฉันถูกอัปโหลดไหม?

ไม่ pattern และข้อความทดสอบของคุณถูกประเมินทั้งหมดในเบราว์เซอร์และไม่ออกจากอุปกรณ์ของคุณ

แหล่งข้อมูล

ฝังเครื่องมือนี้

เพิ่มเครื่องมือนี้ลงในเว็บไซต์ของคุณเอง คัดลอกสคริปต์ด้านล่าง โดยจะอัปเดตให้เป็นปัจจุบันโดยอัตโนมัติ

<iframe src="https://monu.tools/embed/th/regex-tester" width="100%" height="640" style="border:1px solid #e5e5e5;border-radius:12px;max-width:680px" loading="lazy" title="Monu Tools"></iframe>

เครื่องมือที่เกี่ยวข้อง