Penguji Regex

Tren 🔥

Uji ekspresi reguler secara langsung

Alat Developer

Cara Menggunakan Penguji Regex

  1. 1Masukkan ekspresi reguler di kolom atas
  2. 2Tulis teks uji di area teks
  3. 3Kecocokan segera disorot
  4. 4Lihat penjelasan struktur ekspresi

Tentang Penguji Regex

Penguji Regex adalah alat interaktif untuk menulis, menguji, dan men-debug ekspresi reguler secara real-time.

Fitur Utama Penguji Regex

  • Real-time match highlighting as you type the pattern
  • Displays all matches and their start/end positions
  • Shows capture groups and named groups separately
  • Supports flags: g (global), i (case-insensitive), m (multiline), s (dotAll), u (unicode)
  • Match count displayed prominently
  • Works entirely in-browser using JavaScript RegExp
  • Pattern explanation sidebar to understand each part of the regex
  • Compatible with Node.js and all major JavaScript runtimes

Contoh

Validate an email address format

Test a regex pattern that matches standard email address formats.

Input

Pattern: ^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,}$ | Test: "user@example.com" and "invalid-email"

Output

"user@example.com" — 1 match | "invalid-email" — 0 matches

Extract all URLs from a block of text

Use a global pattern to find all HTTP/HTTPS URLs in a text string.

Input

Pattern: https?://[^\s]+ (with g flag) | Test: text containing multiple URLs

Output

All URLs highlighted, each shown as a separate match

Kasus Penggunaan Umum

  • Testing and iterating on input validation patterns (email, phone, postal code)
  • Building log parsing patterns to extract structured data from log lines
  • Writing search-and-replace patterns for code editors and scripts
  • Learning regular expression syntax interactively with immediate feedback
  • Debugging regex patterns that behave differently than expected in code
  • Extracting specific fields from structured text like CSV rows or configuration lines

Pemecahan Masalah

Pattern matches nothing but looks correct

Solusi

Check that the global (g) flag is set if you expect multiple matches. Without the g flag, JavaScript's test() and exec() methods find only the first match.

Backslashes in the pattern are not working

Solusi

In JavaScript regex literals, \d, \w, \s are valid. If you are pasting a pattern from a string literal that used double backslashes (\\d), remove the extra backslash — the tool uses regex literal syntax.

Regex causes the browser to hang or become unresponsive

Solusi

Catastrophic backtracking can occur with certain patterns on long inputs — for example, nested quantifiers like (a+)+ on a non-matching input. Simplify the pattern or test with shorter strings first.

Pertanyaan yang Sering Diajukan

What regex engine is used?

The tool uses the JavaScript native RegExp engine, compatible with modern regex features including lookaheads, lookbehinds, named capture groups, and Unicode property escapes. Patterns tested here work directly in Node.js and browser JavaScript.

What flags are supported?

Global (g) to find all matches, case-insensitive (i), multiline (m) to make ^ and $ match line boundaries, dotAll (s) to make . match newlines, and unicode (u) for full Unicode support.

How do I match a newline?

Use \n to match a newline character in the pattern. If you want . to match newlines as well as other characters, enable the dotAll (s) flag.

What are capture groups?

Capture groups are portions of a regex pattern enclosed in parentheses. They capture the matched text for each group separately. For example, (\d{4})-(\d{2})-(\d{2}) on "2023-11-14" captures "2023", "11", and "14" as three groups.

What is the difference between a greedy and lazy quantifier?

Greedy quantifiers (like +, *) match as much as possible. Lazy/non-greedy quantifiers (like +?, *?) match as little as possible. For example, .+? stops at the first match, while .+ continues to the end of the line.

Can I test patterns with Unicode characters?

Yes. Enable the unicode (u) flag to use Unicode property escapes like \p{Letter} and correctly handle surrogate pairs and characters outside the Basic Multilingual Plane.

Is my data sent to a server?

No. All regex matching is performed locally in your browser using the native JavaScript RegExp engine. Your patterns and test strings never leave your device.

Can I use this regex in other programming languages?

The JavaScript RegExp flavor is similar to but not identical to Python, Java, or PCRE regex. Lookaheads, basic quantifiers, and character classes are broadly compatible. Language-specific features (like Python's (?P<name>) syntax) will need adjustment.