Toolkernel
  • CSV
  • JSON
  • Regex
  • PDF
  • JWT
  • YAML
  • Cron
Toolkernel

Free, privacy-focused developer tools that run entirely in your browser.

  • ✓ 100% browser-based
  • ✓ No data uploaded
  • ✓ Free forever

JSON & CSV

  • JSON Formatter
  • JSON Compare
  • JSON Auto-Fix
  • CSV Cleaner & Merger
  • YAML Formatter

PDF Tools

  • Merge PDF
  • Split PDF
  • Compress PDF
  • PDF to Images
  • All PDF Tools

More Tools

  • Regex Tester
  • JWT Decoder
  • Cron Builder

© 2026 Toolkernel. All rights reserved.

Your files never leave your device. Built for developers who value privacy.

  1. Toolkernel
  2. /
  3. Regex Tools
Your patterns and data never leave your device

Test & DebugRegular Expressions

Live pattern matching with explanations, a pattern library, and code generation for JavaScript, Python, Go, and Java. All processing happens in your browser—fast, private, and free.

Live Matching
Pattern Explain
Pattern Library
Code Generator
Open Regex Tester
🔍

Live Pattern Matching

See matches highlighted in real-time as you type your pattern and test string

📖

Pattern Explanation

Understand each part of your regex with detailed token-by-token explanations

💻

Code Generator

Generate ready-to-use code for JavaScript, Python, Go, and Java

📚

Pattern Library

Common patterns for email, URL, phone, dates, and more - ready to use

100%
Browser-based
0
Data uploaded
∞
Patterns tested

Complete Regex Testing Guide

A powerful browser-based tool for testing, debugging, and learning regular expressions. Features live matching, pattern explanations, code generation for JavaScript, Python, Go, and Java, and a comprehensive pattern library. All processing happens locally—your data never leaves your device.

🔍Live matching
📖Pattern explanation
💻Code generator
📚Pattern library
🚩All regex flags
📋Match groups
Open Regex TesterTry JSON Tools

Editor Interface

The Regex Tester features a comprehensive layout with pattern input, test string, match results, and powerful tools like pattern explanation and code generation.

1

Pattern Input

The pattern input is where you enter your regular expression. The tool validates your pattern in real-time and shows any syntax errors immediately. You can toggle regex flags (global, case-insensitive, multiline, etc.) using the buttons next to the input.

How to Use

  • Enter your regex pattern without the surrounding slashes
  • Click flag buttons (g, i, m, s, u) to toggle matching options
  • Watch for the green checkmark indicating a valid pattern
  • If there's an error, the message shows exactly what's wrong
  • Use the 'Explain' button to see a breakdown of your pattern
2

Test String Panel

Enter or paste the text you want to test your pattern against. Matches are highlighted in real-time as you type. Different colors indicate different capture groups, making it easy to see what each part of your pattern matches.

How to Use

  • Paste or type the text you want to search through
  • Matches are highlighted automatically as you type
  • Hover over a match to see its group information
  • Use the line numbers to reference specific matches
  • Toggle 'Show Whitespace' to see spaces, tabs, and newlines
3

Match Results

The results panel shows all matches found, including their position in the text, captured groups, and named groups if any. Each match is expandable to show detailed information about what was captured.

How to Use

  • See the total match count at the top of the panel
  • Click on any match to highlight it in the test string
  • Expand matches to see all captured groups
  • Named groups are shown with their names for easy reference
  • Copy individual matches or all matches to clipboard

100% Private & Secure

Your regex patterns and test data never leave your browser. Perfect for testing patterns with sensitive data like passwords, API keys, or personal information.

All regex testing happens locally in your browser
Your patterns and test strings never leave your device
Perfect for testing patterns with sensitive data (passwords, API keys)
No server logs of your regex patterns or test data
Works offline once the page is loaded
No account required - start testing immediately

Regex Syntax Reference

Comprehensive documentation for regex syntax. Click to expand each section for detailed explanations, examples, and tips.

Character classes let you match specific sets of characters. They're the building blocks of most regex patterns, from matching single characters to complex character ranges.

Literal Characters

Most characters match themselves exactly. Letters, numbers, and many symbols are matched literally in your pattern.

Syntaxabc123
ExamplePattern: "hello" matches the exact string "hello"
TipSpecial characters like . * + ? need to be escaped with a backslash

Dot (Any Character)

The dot matches any single character except newline. With the 's' flag, it also matches newlines.

Syntax.
Example"h.t" matches "hat", "hot", "hit", "h9t", "h@t"
TipUse [\s\S] to match any character including newlines without the s flag

Character Sets

Square brackets define a set of characters to match. Any single character from the set will match.

Syntax[abc] or [a-z]
Example"[aeiou]" matches any vowel, "[0-9]" matches any digit
TipUse [^...] to match any character NOT in the set

Word Characters

\w matches any word character (letters, digits, underscore). Equivalent to [a-zA-Z0-9_].

Syntax\w and \W
Example"\w+" matches "hello", "user_123", "café" (with u flag)
Tip\W matches any NON-word character (spaces, punctuation, etc.)

Digit Characters

\d matches any digit character (0-9). \D matches any non-digit character.

Syntax\d and \D
Example"\d{3}-\d{4}" matches "555-1234"
TipFor Unicode digits, use the u flag

Whitespace Characters

\s matches any whitespace character (space, tab, newline, carriage return, form feed). \S matches non-whitespace.

Syntax\s and \S
Example"hello\s+world" matches "hello world" with any amount of space

Quantifiers specify how many times a character or group should be matched. They're essential for matching variable-length patterns like words, numbers, or repeated structures.

Zero or More (*)

The asterisk matches the preceding element zero or more times. It's greedy by default, matching as much as possible.

Syntax*
Example"ab*c" matches "ac", "abc", "abbc", "abbbbbc"
TipUse *? for lazy (non-greedy) matching to match as few as possible

One or More (+)

The plus sign matches the preceding element one or more times. Unlike *, it requires at least one occurrence.

Syntax+
Example"ab+c" matches "abc", "abbc" but NOT "ac"
TipUse +? for lazy matching

Zero or One (?)

The question mark makes the preceding element optional - it matches zero or one time.

Syntax?
Example"colou?r" matches both "color" and "colour"
TipAlso used after other quantifiers for lazy matching

Exact Count {n}

Curly braces with a single number match exactly that many occurrences of the preceding element.

Syntax{n}
Example"\d{4}" matches exactly 4 digits like "2024"

Range {n,m}

Curly braces with two numbers match between n and m occurrences (inclusive).

Syntax{n,m}
Example"\d{2,4}" matches 2 to 4 digits: "12", "123", "1234"

Minimum {n,}

Curly braces with a number and comma match n or more occurrences.

Syntax{n,}
Example"\w{3,}" matches words with 3 or more characters

Lazy vs Greedy

By default, quantifiers are greedy (match as much as possible). Add ? to make them lazy (match as little as possible).

Syntax*? +? ?? {n,m}?
ExampleFor "aaa", "a+" matches "aaa" but "a+?" matches just "a"
TipLazy matching is crucial when parsing HTML tags or quoted strings

Anchors don't match characters - they match positions in the string. Use them to ensure your pattern matches at specific locations like the start of a line or at word boundaries.

Start of String (^)

The caret matches the position at the start of the string. With the 'm' flag, it also matches after each newline.

Syntax^
Example"^Hello" matches "Hello world" but not "Say Hello"
TipInside [], the caret means negation, not start anchor

End of String ($)

The dollar sign matches the position at the end of the string. With the 'm' flag, it also matches before each newline.

Syntax$
Example"world$" matches "Hello world" but not "world tour"

Word Boundary (\b)

\b matches the boundary between a word character and a non-word character. It's zero-width, meaning it doesn't consume characters.

Syntax\b
Example"\bcat\b" matches "cat" in "the cat sat" but not in "category"
TipEssential for matching whole words only

Non-Word Boundary (\B)

\B matches any position that is NOT a word boundary. Useful for matching within words.

Syntax\B
Example"\Bcat" matches "cat" in "bobcat" but not in "cat sat"

Groups let you treat multiple characters as a single unit. Capturing groups also save the matched text for later use in replacements or backreferences.

Capturing Groups

Parentheses create a capturing group. The matched content is saved and can be referenced with $1, $2, etc. in replacements.

Syntax(pattern)
Example"(\w+)@(\w+)" captures username and domain separately
TipGroups are numbered from left to right, starting at 1

Named Groups

Named groups let you reference captures by name instead of number. More readable and maintainable.

Syntax(?<name>pattern)
Example"(?<user>\w+)@(?<domain>\w+)" creates named captures
TipReference with $<name> in replacements

Non-Capturing Groups

When you need grouping but don't need to capture, use non-capturing groups. They're slightly faster and don't affect group numbering.

Syntax(?:pattern)
Example"(?:https?://)?(\w+)" groups protocol but only captures domain
TipUse when you only need grouping for quantifiers or alternation

Backreferences

Backreferences match the same text that was captured by an earlier group. Useful for matching repeated patterns.

Syntax\1, \2, ... or \k<name>
Example"(\w+) \1" matches "the the" or "is is" (repeated words)
TipGreat for finding duplicate words or matching quotes

Alternation

The pipe character acts as an OR operator, matching either the pattern before or after it.

Syntaxa|b
Example"cat|dog" matches either "cat" or "dog"
TipUse groups to limit the scope: (cat|dog)s matches cats or dogs

Lookarounds are zero-width assertions that check for patterns without including them in the match. They're powerful for complex matching conditions.

Positive Lookahead

Matches the current position only if the pattern ahead matches. Doesn't consume characters.

Syntax(?=pattern)
Example"\w+(?=@)" matches "user" in "user@email.com"
TipUse for finding words followed by specific characters

Negative Lookahead

Matches the current position only if the pattern ahead does NOT match.

Syntax(?!pattern)
Example"\d+(?!\$)" matches digits NOT followed by $
TipUseful for exclusion patterns

Positive Lookbehind

Matches the current position only if the pattern behind matches. The lookbehind itself isn't part of the match.

Syntax(?<=pattern)
Example"(?<=\$)\d+" matches "100" in "$100" but not in "100"
TipLookbehinds must have fixed length in most regex engines

Negative Lookbehind

Matches the current position only if the pattern behind does NOT match.

Syntax(?<!pattern)
Example"(?<!\d)\d{3}(?!\d)" matches exactly 3 digits not part of longer number

Flags modify how the regex engine interprets and applies your pattern. They're essential for case-insensitive matching, multiline text, and Unicode support.

Global Flag (g)

Without the global flag, regex stops after the first match. The global flag finds all matches in the string.

Syntax/pattern/g
ExampleWith "a" pattern on "banana": without g → 1 match, with g → 3 matches
TipAlways use for find-all operations and replacements

Case Insensitive (i)

Makes the pattern case-insensitive. 'a' will match both 'a' and 'A'.

Syntax/pattern/i
Example"/hello/i" matches "Hello", "HELLO", "hElLo"

Multiline Mode (m)

Changes the behavior of ^ and $. They match the start/end of each line, not just the string.

Syntax/pattern/m
Example"^\w+" with m flag matches first word of EACH line
TipEssential for processing multi-line text like logs

Dotall Mode (s)

Makes the dot (.) match newline characters too. Normally, dot matches everything EXCEPT newlines.

Syntax/pattern/s
Example"<div>.*</div>" with s flag matches div content spanning multiple lines

Unicode Mode (u)

Enables full Unicode matching. Required for matching Unicode characters and properties correctly.

Syntax/pattern/u
Example"\p{L}+" matches letters from any language (with u flag)
TipUse for international text and emoji

Ready-to-use regex patterns for common validation, extraction, and formatting tasks. Click on any pattern in the Regex Tester to load it instantly.

✅validation Patterns

Email Address

Validates email addresses with common formats. Matches most real-world email addresses.

^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,}$
Examples: user@example.com, john.doe@company.co.uk, test+filter@gmail.com
URL

Matches HTTP and HTTPS URLs with optional path. Captures domain components.

^(https?:\/\/)?([\w.-]+)\.([a-z]{2,})(\/[\w./-]*)?$
Examples: https://example.com, http://sub.domain.org/path/page, example.com
Phone Number (US)

Matches US phone numbers in various formats including parentheses and separators.

^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$
Examples: (555) 123-4567, 555-123-4567, 5551234567, 555.123.4567
Phone Number (International)

Matches international phone numbers in E.164 format.

^\+?[1-9]\d{1,14}$
Examples: +14155551234, +442071234567, 14155551234
IPv4 Address

Validates IPv4 addresses with proper range checking (0-255 for each octet).

^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$
Examples: 192.168.1.1, 10.0.0.255, 172.16.0.1
IPv6 Address

Matches full IPv6 addresses (without shorthand notation).

^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$
Examples: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
Date (YYYY-MM-DD)

Matches ISO 8601 date format with basic validation for month and day ranges.

^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$
Examples: 2024-01-15, 2023-12-31, 2025-06-01
Time (24-hour)

Matches 24-hour time format with optional seconds.

^([01]\d|2[0-3]):([0-5]\d)(?::([0-5]\d))?$
Examples: 14:30, 23:59:59, 00:00:00, 09:05
Hex Color Code

Matches 3 or 6 digit hex color codes with optional # prefix.

^#?([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$
Examples: #FF5733, #fff, ABC123, a1b
UUID

Matches UUID/GUID format with version and variant validation.

^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
Examples: 550e8400-e29b-41d4-a716-446655440000, 6ba7b810-9dad-11d1-80b4-00c04fd430c8
Username

Alphanumeric username starting with a letter, 3-16 characters, allowing underscores and hyphens.

^[a-zA-Z][a-zA-Z0-9_-]{2,15}$
Examples: john_doe, User123, dev-ninja

🔍extraction Patterns

HTML Tag

Matches HTML tags with their content. Captures tag name and inner content.

<([a-z][a-z0-9]*)\b[^>]*>(.*?)<\/\1>
Examples: <div>content</div>, <p>paragraph</p>, <span>text</span>
Markdown Link

Extracts markdown links, capturing link text and URL separately.

\[([^\]]+)\]\(([^)]+)\)
Examples: [Click here](https://example.com), [Documentation](/docs)
Quoted String

Matches single or double quoted strings, handling escaped quotes.

(["'])(?:(?!\1)[^\\]|\\.)*\1
Examples: "Hello, World!", 'It\'s working', "Say \"Hello\""
Duplicate Words

Finds repeated words like 'the the' or 'is is'. Useful for proofreading.

\b(\w+)\s+\1\b
Examples: the the, is is, and and

🔧formatting Patterns

Slug (URL-friendly)

Matches URL-friendly slugs with lowercase letters, numbers, and hyphens.

^[a-z0-9]+(?:-[a-z0-9]+)*$
Examples: my-blog-post, product-123, about-us
Trailing Whitespace

Matches spaces or tabs at the end of lines. Use with multiline flag.

[ \t]+$
Examples: text , line
Multiple Spaces

Matches 2 or more consecutive spaces. Use for normalizing whitespace.

{2,}
Examples: too many spaces

🛡️security Patterns

Credit Card Number

Matches Visa, Mastercard, and American Express card numbers (without spaces).

^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13})$
Examples: 4111111111111111, 5500000000000004, 340000000000009
Strong Password

Requires at least 8 characters with uppercase, lowercase, number, and special character.

^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$
Examples: SecureP@ss1, MyP@ssw0rd!, Test123$xyz

Regular expressions are essential for many development tasks. Here are common scenarios where regex can save you hours of manual work.

✅

Form Validation

Validate user input in real-time before form submission. Check email formats, phone numbers, passwords, and custom fields.

  • Email validation before user registration
  • Password strength requirements
  • Phone number format validation
  • Credit card number verification
🔍

Log Analysis

Parse log files to extract timestamps, IP addresses, error codes, and other structured data from unstructured text.

  • Extract IP addresses from access logs
  • Find error patterns in application logs
  • Parse timestamps across different formats
  • Filter logs by severity level
📝

Text Processing

Clean and transform text data by removing unwanted characters, normalizing formats, or extracting specific patterns.

  • Remove HTML tags from text
  • Normalize phone numbers to consistent format
  • Extract URLs from documents
  • Clean up whitespace and formatting
🔄

Data Transformation

Reformat data from one structure to another using capture groups and replacement patterns.

  • Convert date formats (MM/DD/YYYY to YYYY-MM-DD)
  • Restructure CSV column data
  • Transform camelCase to snake_case
  • Reorder name formats (Last, First to First Last)
🛡️

Security & Sanitization

Detect and filter potentially malicious input, validate security-sensitive data, and sanitize user content.

  • Detect SQL injection patterns
  • Validate and sanitize URLs
  • Find exposed API keys or secrets
  • Filter profanity or unwanted content
💻

Code Refactoring

Search and replace across codebases using regex to rename variables, update API calls, or migrate patterns.

  • Rename functions across files
  • Update deprecated API patterns
  • Convert string concatenation to template literals
  • Find and fix common code smells

Writing effective regex takes practice. Here are essential tips to help you write better patterns.

Start Simple

Build your regex incrementally. Start with a simple pattern and add complexity as needed.

Use Anchors

Use ^ and $ to ensure your pattern matches the entire string, not just a part of it.

Be Specific

Avoid .* when possible. Use specific character classes like \d or \w for better precision.

Test Edge Cases

Always test with empty strings, very long strings, and unexpected input.

Consider Performance

Avoid nested quantifiers like (a+)+ which can cause catastrophic backtracking.

Use Non-Capturing Groups

Use (?:...) when you need grouping but don't need to capture the match.

Related Developer Tools

📋

JSON Formatter & Validator

Format, validate, compare, and minify JSON data. Features regex-powered search within JSON structures.

Try JSON Tools
📊

CSV Cleaner & Merger

Clean CSV data with regex-powered find & replace. Merge files, remove duplicates, and transform columns.

Try CSV Tools