Regular Expression Pattern
Test Text
Pattern Breakdown
Pattern explanation will appear here
Match Results
Enter a valid regex pattern to start
關於此工具
正則表達式測試器讓您能夠透過即時視覺回饋即時測試、除錯和驗證正則表達式。在您輸入時查看突顯的匹配,透過自動解釋了解您模式的每個部分的作用,並使用擷取群組測試替換。無論您是驗證使用者輸入、解析日誌還是提取資料模式,此工具都能幫助您更快地編寫更好的正則表達式。透過超過13個快速範例、內建的速查表以及JavaScript、Python、PHP和Java的程式碼生成,您將毫無挫折地掌握正則表達式。所有處理都在您的瀏覽器中進行——您的模式和測試資料完全保持私密。
使用方式
輸入您的正則表達式模式(有或沒有像 /pattern/flags 這樣的分隔符)。切換 global(g)、case-insensitive(i)、multiline(m)等標誌。貼上您的測試文字,並即時查看突顯的匹配。查看模式分解以了解每個組件。使用尋找和替換模式測試文字替換。用您喜歡的語言生成程式碼。將常用模式儲存到本地函式庫以便快速存取。
限制與重要提示
使用 JavaScript 正則表達式引擎(ECMA-262)。對於 Python、Java 或 PCRE(PHP),模式可能需要調整。具有過度回溯的複雜模式可能會減慢或掛起瀏覽器。非常大的文字(超過1MB)可能會影響效能。對於生產環境,盡可能使用經過測試的驗證函式庫(validator.js、Joi、Yup)。單獨的正則表達式無法完全驗證複雜格式——電子郵件需要 DNS 檢查,日期需要日曆邏輯。
Technical Details
Edge Cases & Tricky Inputs
- •Lookbehind assertions are supported in Chrome/Edge but may fail in Safari < 16.4.
- •The /u flag enables Unicode mode — required for matching emoji and non-BMP characters.
- •Named capture groups (?<name>...) work in all major browsers since 2018.
Performance & Processing
- •Catastrophic backtracking (e.g., (a+)+ against "aaaa...") is detected and the regex is terminated after a timeout.
- •Match highlighting updates in real-time as you type the pattern.
Developer Notes
- •Supports flags: g (global), i (case-insensitive), m (multiline), s (dotAll), u (unicode), y (sticky).
- •Common patterns library includes email, URL, IP address, date, phone number, and more.
Known Limitations
- •PCRE-specific features (recursive patterns, conditional subpatterns) are not supported — this uses JavaScript regex engine.
- •Replacement with function callbacks is not available in the UI.
Related Tool Collections
Git & DevOps
Generate commit messages, .gitignore files, and manage development workflows.
Explore related topics: