Regex Tester

Regular expression to test
Flags
String to test Generate a string from RegEx (Beta)

Explanation

Substitution


This online tool allows you to test regular expression in JavaScript and PCRE (Python, PHP). It also allows you to generate a string example from a RegEx.

You can consult the regex Quick Start or see the full user guide to help you to use this regular expression tester.

User guide

  • Step 0: Choose the regex engine: JavaScript or PCRE (PHP, Python).
  • Step 1: Copy and paste or directly type your regular expression to test in the "Regular expression to test" field.
  • Step 2: Select the flags you want in "Flags" section.
  • Step 3: Copy and paste or directly type your test string in the "test string" field.
  • As soon as you make a modification (regular expression, flags or test string):
    • Step 4: An explanation is generated about of your regex. It uses regulex, it is a JavaScript Regular Expression Parser & Visualizer (Written in pure JavaScript).
    • Step 5: A message indicates the number of correspondence
    • Your regex is highlighted according to the syntax. It is a beta version, it can be wrong.

    regex tester user guide

  • You can also replace regular expression matches in text with a replacement string.

    Step 6: Copy and paste or directly type your substitute string in the "Substitution" field.

    Step 7: Substitutions are automatically performed on your test string.

    regex tester user guide

  • You can save your regex in order to share it. You can protect your share with a password, so only you can change it. See "Save and Share" section:

    share regex tester

  • Generate a string from RegEx (Beta):
    Clicks on "Generate a string from RegEx (Beta)" in order to generate a string that matches with the regex.

    Substitutions are not managed.


    The unavoidables

    Some regex that can be useful (without warranty).

    Email address

    The last RFC is complex, there is no reliable solution, this regex should work more than 99% of the time (You must turn off case sensitivity).

    ^((?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\]))$

    Alphanumeric

    The regex below allows to validate alphanumeric string. Be careful, \w authorizes the underscore character.

    ^[a-zA-Z0-9]+$

    MD5

    The regex below allows to validate MD5 string.

    ^[a-f0-9]{32}$

    IP V4

    The regex below allows to validate IP v4.

    ^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$


    About regular expression

    A regular expression is a sequence of characters that define a search pattern. This pattern is used by string searching algorithms for find or replace text.

    It can be useful to validate an EMAIL address or an IP address.


    Regular expression tester

    This tool is an online regex checker, it allows to easily test and debug regex. This avoids wasting time writing the few lines of code needed to do the tests.

    This tool also allows you to share your regular expressions, this can be useful when you want to explain one of your regex problems (or its resolution) on a forum.



    Save regular expression
    Your regex has been permanently saved and you (or anybody) can access with this link:
    Password
    Choice a password to modify/delete this regex later Enter password to modify this regex. Enter password to delete this regex. Enter the new password for the fork.
    You can report a bug or give feedback by adding a comment (below) or by clicking "Contact me" link (at the top right hand corner of the page).

    Comments




    Dietmar Schindler-2020-03-10 14:23
    If the expression isn't understood by the engine, the error message is visible too shortly.
    Also it would be important to know which Python version is used for the Python RegEx engine
    (it seems to not understand "(?i:…)").
    Example: \b(([A-Z])([A-Z])?([A-Z])?([A-Z])?) (?:\w+ ){,1}\(?from .*?(?P<full>\2.*?(?i:\3?.*?\4?.*?\5?).*?)\b


    Cyril-2020-03-21 15:23
    Yes, I will add it!