Regex Tester & Debugger

Regular expression to test
Flags
String to test Generate a string from RegEx

Explanation:

Substitution:

Documentation

Anchors
$ End of string or end of line (in multi-line pattern)
^ Start of string or start of line (in multi-line pattern)
\b Word boundary
\B Not word boundary
Quantifiers
x? 0 or 1
x+ 1 or more
* 0 or more
{2} Exactly 2
{2,} 2 or more
{2,5} Between 2 and 5
Metacharacters
. Any single character except line break (\n, \r)
\w Word character
\W Non-word character
\d Digit
\D Non-digit character
\s Whitespace character ([ \f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff])
\S Non-whitespace character
\b Beginning/end of a word
\B Not at the beginning/end of a word
\n New line character
\r Carriage return character
\t Tab character
\v Vertical tab character
\0 NUL character
\f Form feed character
\xxx Character specified by an octal number xxx
\xdd Character specified by an hexadecimal number dd
\udddd Unicode character specified by an hexadecimal number dddd
Brackets
[xyz] Any character between the brackets
[^xyz] Any character not between the brackets
[x-z] Any character from x to z
[^x-z] NOT (Any character from x to z)
(x|y) Any of the alternatives specified

Regex Tester & Debugger


A Regex Tester and Debugger is a free online tool designed to assist developers and users in testing, debugging, and refining regular expressions (regex or regexp). Regular expressions are patterns used for matching and manipulating text. They are powerful but can be complex, and creating them correctly can sometimes be challenging. A regex tester and debugger helps simplify this process by providing a user-friendly interface for working with regular expressions.

Here are the primary features and functionalities typically offered by a Regex Tester & Debugger:

  • Pattern Testing: You can input a regular expression pattern and a sample text or string to test how the pattern matches against the text. The tool will highlight the matched portions of the text and provide details on matches.
  • Matching Flags: Many regex testers allow you to set matching flags, such as case-insensitive matching or multi-line matching, to test how the pattern behaves under different conditions.
  • Match Highlighting: The tool highlights matched portions of the text, making it easier to visualize which parts of the text match the pattern.
  • Match Details: It provides detailed information about each match, including the matched text, the start and end positions of matches, and the capturing groups if used.
  • Regex Syntax Highlighting: Syntax highlighting helps you write and understand regular expressions by color-coding different elements of the pattern.
  • Replace Testing: Some tools allow you to test regex-based text replacement, where you can preview how a replacement pattern will affect the text.
  • Debugging: If there are issues with the regular expression, a debugger can help identify and explain errors in the pattern. It may also provide suggestions for fixing common mistakes.
  • Regex Library: Some regex testers include a library of common regex patterns and examples that you can use as a reference or starting point.
  • Support for Multiple Programming Languages: Many regex testers support various programming languages and regex flavors, such as JavaScript, Python, Perl, and more, allowing you to test regex patterns relevant to your development environment.
  • Export and Share: You can often export regex patterns or share them with others, making it easier to collaborate on regular expression tasks.

Regular expressions are widely used in programming, data extraction, text manipulation, and validation tasks. A regex tester and debugger can significantly speed up the process of creating and fine-tuning regex patterns, reducing the likelihood of errors and improving productivity for developers and data analysts.

Examples:

Regex testers and debuggers are commonly used to test and debug regular expressions in various contexts, such as data validation, text manipulation, and pattern matching. Below are some examples of how you might use a regex tester and debugger:


Email Address Validation:

Regular Expression: ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$

Use a regex tester to:

  • Input an email address like [email protected].
  • Test if it matches the regex pattern for a valid email address.
  • Verify that it returns a match, indicating a valid email format.

Phone Number Extraction:

Regular Expression: \b\d{3}[-.\s]?\d{3}[-.\s]?\d{4}\b

Use a regex tester to:

  • Input a text containing phone numbers like "Call 555-123-4567 for assistance."
  • Test the regex to extract phone numbers.
  • Verify that it captures and displays 555-123-4567 as a match.

Date Format Conversion:

Regular Expression: (\d{2})/(\d{2})/(\d{4})

Replacement Pattern: $3-$1-$2

Use a regex tester to:

  • Input a date in the format mm/dd/yyyy like 05/25/2023.
  • Test the regex pattern to capture day, month, and year components.
  • Apply a replacement pattern to convert the date to yyyy-mm-dd, resulting in 2023-05-25.

HTML Tag Matching:

Regular Expression: <([a-zA-Z]+)[^>]*>(.*?)<\/\1>

Use a regex tester to:

  • Input an HTML snippet containing tags like <div class="content">Some text</div>.
  • Test the regex pattern to capture the tag name (div) and its content (Some text) within the matched pair.

URL Extraction:

Regular Expression: (https?|ftp):\/\/[^\s/$.?#].[^\s]*

Use a regex tester to:

  • Input a text containing URLs like Visit my website at https://example.com.
  • Test the regex pattern to extract URLs.
  • Verify that it captures https://example.com as a match.

Password Strength Validation:

Regular Expression: ^(?=.*[A-Z])(?=.*[a-z])(?=.*\d).{8,}$

Use a regex tester to:

  • Input a password like Passw0rd.
  • Test the regex pattern for password strength.
  • Verify that it returns a match, indicating a strong password with at least one uppercase letter, one lowercase letter, one digit, and a minimum length of 8 characters.

In each of these examples, a regex tester and debugger would allow you to input the regex pattern, sample text, or data, and observe the matching behavior, matches, and captured groups. This iterative process helps in fine-tuning regular expressions for specific tasks and ensures they work as expected in your applications or scripts.

Similar tools

JSON validator & beautifier

Validate JSON content and make it looks good.

5,398
XML to JSON

Convert XML snippets to raw JSON code.

4,946
Javascript Beautifier/formatter

Beautify your Javascript by removing all the unnecessary characters.

5,966

Popular tools