🧩
正規表現ビジュアライザー
ビジュアライザー テスター コード生成Understand, test, and debug regular expressions with interactive visualizations and real-time explanations.
/
/
2 matches
const regex = /([A-Z])w+/g;
const str = '';
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
Visualization
Generating diagram...
Explanation
Match Results
| Match # | Full Match | Groups | Index |
|---|
Character Classes
| Pattern | Matches |
|---|---|
\\d | Any digit (0-9) |
\\w | Word char (a-z, A-Z, 0-9, _) |
\\s | Whitespace |
. | Any char except newline |
[abc] | Any of a, b, or c |
[^abc] | Not a, b, or c |
Quantifiers
| Pattern | Meaning |
|---|---|
* | 0 or more |
+ | 1 or more |
? | 0 or 1 |
{n} | Exactly n |
{n,m} | Between n and m |
Anchors & Groups
| Pattern | Meaning |
|---|---|
^ | Start of string |
$ | End of string |
(...) | Capture group |
(?:...) | Non-capture group |
(?=...) | Lookahead |
\\b | Word boundary |
Common Patterns
| Pattern | Matches |
|---|---|
^[\\w.+-]+@[\\w-]+\\.[\\w.]+$ | |
^https?:\/\/ | URL |
^\\d{4}-\\d{2}-\\d{2}$ | Date (YYYY-MM-DD) |
^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$ | IPv4 |
What are Regular Expressions?
Regular expressions (regex) are powerful patterns used to match character combinations in strings. They are essential tools for text processing, validation, and data extraction across programming languages. Regex patterns consist of literal characters and special metacharacters that define search rules. They are used in form validation, log parsing, search and replace operations, and data cleaning tasks.
How to Use This Tool
Enter your regex pattern in the input field. The tool will automatically generate a railroad diagram visualizing the pattern structure. Add test text to see real-time match highlighting and explanations. Use the cheatsheet for quick reference on common patterns and syntax. Generate code snippets for your preferred programming language.
Common Use Cases
Email validation to ensure user input matches proper email format before processing, log parsing to extract timestamps and IP addresses from server logs, data cleaning to remove unwanted characters or format phone numbers consistently, and search and replace for bulk text transformations with pattern matching.
Pro Tips
Start simple and build complex patterns incrementally. Use non-capturing groups (?:) when you do not need to reference the match. Test edge cases like empty strings and special characters. Consider regex readability — complex patterns can be documented with comments.