跳至正文

正規表示式測試器

測試正規表示式模式並即時確認配對結果的免費線上工具。

//

Flags

  • g - Global: Find all matches
  • i - Case insensitive
  • m - Multiline: ^ and $ match line breaks
  • s - Dotall: . matches newlines
  • u - Unicode: Full unicode support

Common Syntax

  • . - Any character
  • \d - Digit (0-9)
  • \w - Word character (a-z, A-Z, 0-9, _)
  • \s - Whitespace
  • * - 0 or more
  • + - 1 or more
  • ? - 0 or 1
  • [abc] - Any of a, b, or c
  • (abc) - Capture group

主要功能

  • 即時配對:輸入後立即確認結果
  • 5 種旗標:支援 g、i、m、s、u
  • 醒目提示顯示:視覺化顯示配對部分
  • 群組擷取:提供擷取群組詳細資訊
  • 一般模式:提供常用的模式
  • 位置資訊:顯示各配對的起始/結束位置

旗標說明

旗標名稱說明
gGlobal尋找所有配對(不只第一個)
iIgnore Case不區分大小寫
mMultiline^和$ 配對各行的起始/結束
sDotall. 也配對換行
uUnicode完整支援 Unicode

一般模式範例

電子郵件

\w+@\w+\.\w+

配對:user@example.comadmin@test.org

URL

https?://[\w\-._~:/?#\[\]@!$&'()*+,;=]+

配對:http://example.com、https://site.com/page

電話號碼

\+?\d{1,4}?[-.\s]?\(?\d{1,3}?\)?[-.\s]?\d{1,4}[-.\s]?\d{1,4}[-.\s]?\d{1,9}

配對:0912-345-678、+886-912-345-678

十六進位顏色

#[0-9a-fA-F]{6}|#[0-9a-fA-F]{3}

配對:#FF5733、#f00

日期(YYYY-MM-DD)

\d{4}-\d{2}-\d{2}

配對:2024-01-15

IP 位址

(?:\d{1,3}\.){3}\d{1,3}

配對:192.168.0.1

相關工具

💬 這個工具對您有幫助嗎?

歡迎隨時向我們發送您的意見或建議!

🔒 隱私權保護

此工具完全在客戶端運作。您輸入的資料不會傳送到伺服器,僅在瀏覽器中處理。