Penguji Regex
Uji dan debug ekspresi reguler dengan pencocokan langsung
Tentang Alat Ini
Regular expressions (regex or regexp) are powerful patterns used to search, match, and manipulate text. They are supported in virtually every programming language and are essential for tasks like input validation, data extraction, log parsing, and text replacement. However, regex syntax can be complex and difficult to debug without the right tools. Our free online regex tester provides a live testing environment where you can write a regex pattern and immediately see all matches highlighted in your test string. It supports JavaScript regex syntax, displays captured groups, shows match details with positions, and includes a comprehensive cheat sheet covering all common patterns, anchors, quantifiers, and flags.
Cara Penggunaan
- Enter your regular expression pattern in the regex input field. You can include flags such as g (global), i (case-insensitive), m (multiline), and s (dotAll) by appending them after the closing delimiter.
- Type or paste your test string into the text area below. All regex matches will be highlighted in real time as you type, with different colors for each capture group.
- Review the match details panel, which shows each match's position, length, and captured group values. This helps you verify that your pattern captures exactly what you intend.
- Use the built-in cheat sheet as a quick reference for regex syntax. Click any pattern in the cheat sheet to insert it into your regex, and experiment with different combinations.
- Iterate on your pattern until all matches are correct. Copy the final regex pattern to use in your JavaScript, Python, Java, or any other language that supports regular expressions.
Pertanyaan yang Sering Diajukan
Contoh
Regex to Validate Email Address
Matches standard email formats. Use for: form validation, user registration, data cleaning.
^[\w.-]+@[\w.-]+\.\w{2,}$Regex for Phone Number (US)
Matches US phone numbers in various formats. Use for: contact forms, CRM data validation.
^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$Regex for URL Validation
Matches HTTP and HTTPS URLs. Use for: link validation, content scraping, SEO analysis.
https?:\/\/[\w.-]+(?:\.[\w.-]+)+[\w\-._~:/?#[\]@!$&'()*+,;=]*$Regex for IP Address (IPv4)
Matches valid IPv4 addresses. Use for: network configuration, log analysis, access control.
^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$Regex for Date Format (YYYY-MM-DD)
Matches dates in ISO format. Use for: data validation, date parsing, log filtering.
^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])$Regex for Password Strength
Requires 8+ chars, uppercase, lowercase, number. Use for: registration forms, security policies.
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$Regex for Chinese Characters
Matches Chinese Unicode characters. Use for: multilingual content validation, NLP processing.
[\u4e00-\u9fff]+Regex for Numbers Only
Matches integers and decimals. Use for: numeric input validation, data extraction.
^\d+(?:\.\d+)?$Regex to Remove HTML Tags
Matches HTML tags for removal. Use for: content cleaning, text extraction, sanitization.
<[^>]+>Regex for Credit Card Number
Matches common credit card formats (Visa, MC). Use for: payment form validation.
^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13})$Extract Email Addresses
Finds all emails in text. Use for: lead generation, contact harvesting, data mining.
[\w.-]+@[\w.-]+\.\w{2,}Extract URLs from Text
Finds HTTP/HTTPS links. Use for: link analysis, content scraping, SEO auditing.
https?:\/\/[\w.-]+(?:\.[\w.-]+)+[\w\-._~:/?#[\]@!$&'()*+,;=]*Extract Hashtags
Finds Twitter/social media hashtags. Use for: social media analysis, trend monitoring.
#[a-zA-Z0-9_]+Extract JSON Values
Matches quoted string values in JSON. Use for: JSON parsing, data extraction.
"(?:[^"\\]|\\.)*"Extract Domain from URL
Extracts domain name. Use for: link analysis, domain filtering, analytics.
https?:\/\/(?:www\.)?([\w.-]+)Replace Multiple Spaces with One
Normalizes whitespace. Use for: text formatting, data cleaning, display purposes.
\s+Remove Non-Alphanumeric Characters
Keeps only letters and numbers. Use for: slug generation, username validation, sanitization.
[^a-zA-Z0-9]Validate Hex Color Code
Matches #RGB or #RRGGBB. Use for: color input validation, CSS parsing.
^#(?:[0-9a-fA-F]{3}){1,2}$Regex for Username
Alphanumeric, 3-16 chars. Use for: registration validation, user management.
^[a-zA-Z0-9_]{3,16}$Match Empty Lines
Finds blank lines. Use for: text formatting, paragraph detection, document cleaning.
^\s*$Regex for Slug/URL-friendly String
Lowercase, hyphens only. Use for: URL generation, SEO-friendly identifiers.
^[a-z0-9]+(?:-[a-z0-9]+)*$Extract Time (HH:MM or HH:MM:SS)
Matches time formats. Use for: log parsing, schedule extraction, data validation.
(?:[01]?\d|2[0-3]):[0-5]\d(?::[0-5]\d)?