Regular Expressions 101

Save & Share

Flavor

  • PCRE2 (PHP >=7.3)
  • PCRE (PHP <7.3)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java 8
  • .NET 7.0 (C#)
  • Rust
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests

Tools

Sponsors
There are currently no sponsors. Become a sponsor today!
An explanation of your regex will be automatically generated as you type.
Detailed match information will be displayed here automatically.
  • All Tokens
  • Common Tokens
  • General Tokens
  • Anchors
  • Meta Sequences
  • Quantifiers
  • Group Constructs
  • Character Classes
  • Flags/Modifiers
  • Substitution
  • A single character of: a, b or c
    [abc]
  • A character except: a, b or c
    [^abc]
  • A character in the range: a-z
    [a-z]
  • A character not in the range: a-z
    [^a-z]
  • A character in the range: a-z or A-Z
    [a-zA-Z]
  • Any single character
    .
  • Alternate - match either a or b
    a|b
  • Any whitespace character
    \s
  • Any non-whitespace character
    \S
  • Any digit
    \d
  • Any non-digit
    \D
  • Any word character
    \w
  • Any non-word character
    \W
  • Non-capturing group
    (?:...)
  • Capturing group
    (...)
  • Zero or one of a
    a?
  • Zero or more of a
    a*
  • One or more of a
    a+
  • Exactly 3 of a
    a{3}
  • 3 or more of a
    a{3,}
  • Between 3 and 6 of a
    a{3,6}
  • Start of string
    ^
  • End of string
    $
  • A word boundary
    \b
  • Non-word boundary
    \B

Regular Expression

/
/
gis

Test String

Code Generator

Generated Code

import java.util.regex.Matcher; import java.util.regex.Pattern; public class Example { public static void main(String[] args) { final String regex = "^(?:[[:^print:][:cntrl:]\\s]|GIF89.{0,20})*(?:<[^>]+>\\s*)+.{0,150}?ilga gate<\\/title>.{0,1300}?var\\s*st\\s*=\\s*'aguardando\\.\\..{0,600}?ajax\\(\\{\\s*url:\\s*'apielo\\.php.{0,1600}?function\\s*esconderdie\\(.{0,3000}?url\\('imagem\\/porn\\.jpg.{0,1100}?>reejected<.{0,3000}?card[<\\/\\w>\\s=\"]+result.{0,2700}?front\\.js\"><\\/script[[:punct:]\\s]+$"; final String string = "<!-- saved from url=(0038)https://chkfull24hr.000webhostapp.com/ -->\n" + "<html><!-- Mirrored from editfly-chk.xyz/ by HTTrack Website Copier/3.x [XR&CO'2014], Thu, 25 Oct 2018 02:18:04 GMT --><!-- Added by HTTrack --><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><!-- /Added by HTTrack -->\n\n" + " \n" + " <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n" + " <title id=\"title\">ᏆhᎬ ᏆᎬᏟhᏒᎥm | ILGA Gate</title>\n" + " <meta name=\"description\" content=\"\">\n" + " <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\">\n" + " <meta name=\"robots\" content=\"all,follow\">\n\n" + " <link rel=\"stylesheet\" href=\"arquivos/bootstrap.min.css\">\n\n" + " <script src=\"arquivos/jquery.min.js\"></script>\n\n" + " <link rel=\"stylesheet\" href=\"arquivos/font-awesome.min.css\">\n\n" + " <link rel=\"stylesheet\" href=\"arquivos/fontastic.css\">\n\n" + " <link rel=\"stylesheet\" href=\"arquivos/css\">\n\n" + " <link rel=\"stylesheet\" href=\"arquivos/style.default.premium.css\" id=\"theme-stylesheet\"><link id=\"new-stylesheet\" rel=\"stylesheet\"><link id=\"new-stylesheet\" rel=\"stylesheet\"><link id=\"new-stylesheet\" rel=\"stylesheet\">\n\n" + " <link rel=\"stylesheet\" href=\"arquivos/custom.css\">\n\n" + " \n" + "<script>\n" + " var audio = new Audio('blop.mp3');\n" + " $(document).ready(function () {\n" + " $('#testar').attr('disabled', null);\n" + " $('#testar').click(function () {\n" + " audio.play();\n" + " \n" + " var line = $('#list').val().split('\\n');\n" + " var total = line.length;\n" + " var ap = 0;\n" + " var rp = 0;\n" + " var st = 'Aguardando...';\n" + " $('#carregadas').html(total);\n" + " \n" + " $('#status').html(st);\n" + " line.forEach(function (value) {\n" + " var list = value.split('|');\n" + " var cc = list[0];\n" + " var mes = list[1];\n" + " var ano = list[2];\n" + " var cvv = list[3];\n" + " var ajaxCall = $.ajax({\n" + " url: 'apielo.php',\n" + " type: 'GET',\n" + " data: 'lista=' + value,\n" + " beforeSend: function () {\n" + " $('#stop').attr('disabled', null);\n" + " $('#testar').attr('disabled', 'disabled');\n" + " var st = 'Testando...';\n" + " $('#status').html(st);\n\n" + " },\n" + " \n" + " success: function(data){\n" + " if(data.indexOf(\"Aprovada\") >= 0){\n" + " $(\"#lives\").val(data + \"\\n\" + $(\"#lives\").val());\n" + " ap = ap + 1;\n" + " document.getElementById(\"lives\").innerHTML += data + \"\";\n" + " audio.play();\n" + " removelinha();\n" + " function escondelive() {\n" + " $('#lives').toggle(200, function () {\n" + " if ($(this).is(':visible')) {\n" + " $('#btn_live').html('<i class=\"fa fa-minus-square\"></i>');\n" + " } else {\n" + " $('#btn_live').html('<i class=\"fa fa-plus-square\"></i>');\n" + " }\n" + " });\n" + "}\n" + " }else{\n" + " $(\"#dies\").val(data + \"\\n\" + $(\"#dies\").val());\n" + " \n" + " rp = rp + 1;\n" + " document.getElementById(\"employe\").innerHTML += data + \"\";\n" + " removelinha();\n" + " function esconderdie() {\n" + " $('#dies').toggle(200, function () {\n" + " if ($(this).is(':visible')) {\n" + " $('#escondedie').html('<i class=\"fa fa-minus-square\">');\n" + " } else {\n" + " $('#escondedie').html('<i class=\"fa fa-plus-square\">');\n" + " }\n" + " });\n" + "}\n\n" + " }\n" + " var fila = parseInt(ap) + parseInt(rp);\n\n" + " $('#cLive').html(ap);\n\n" + " $('#cDie').html(rp);\n" + " $('#total').html(fila);\n" + " var result = (fila/total)*100;\n" + " $('#pct').html(result);\n" + " $('#title').html('[' + fila + '/' + total + '] 𝑮𝑨𝑻𝑬 𝑬𝑳𝑶 𝟔𝟓');\n" + " document.getElementById(\"progreso\").style.width = result + \"%\";\n" + " if (fila == total) {\n" + " $('#testar').attr('disabled', null);\n" + " $('#stop').attr('disabled', 'disabled');\n" + " audio.play();\n" + " var st = 'Finalizado';\n\n" + " \n" + " $('#status').html(st);\n\n" + " }\n\n" + " }\n" + " \n" + " });\n" + " $('#stop').click(function () {\n" + " ajaxCall.abort();\n" + " $('#testar').attr('disabled', null);\n" + " $('#stop').attr('disabled', 'disabled');\n" + " var st = 'Pausado...';\n" + " $('#status').html(st);\n" + " });\n" + " });\n" + " });\n" + " });\n" + " function stopado() {\n" + " var lines = $(\"#list\").val().split('\\n');\n" + " lines.splice(0, 1);\n" + " $(\"#list\").val(lines.join(\"\\n\"));\n" + " }\n" + " function removelinha() {\n" + " var lines = $(\"#list\").val().split('\\n');\n" + " lines.splice(0, 1);\n" + " $(\"#list\").val(lines.join(\"\\n\"));\n" + " }\n" + " </script><style type=\"text/css\">/* Chart.js */\n" + "@-webkit-keyframes chartjs-render-animation{from{opacity:0.99}to{opacity:1}}@keyframes chartjs-render-animation{from{opacity:0.99}to{opacity:1}}.chartjs-render-monitor{-webkit-animation:chartjs-render-animation 0.001s;animation:chartjs-render-animation 0.001s;}</style><style type=\"text/css\">/* Chart.js */\n" + "@-webkit-keyframes chartjs-render-animation{from{opacity:0.99}to{opacity:1}}@keyframes chartjs-render-animation{from{opacity:0.99}to{opacity:1}}.chartjs-render-monitor{-webkit-animation:chartjs-render-animation 0.001s;animation:chartjs-render-animation 0.001s;}</style></head>\n" + " \n\n" + " \n" + "<style type=\"text/css\">\n\n" + "body{\n\n" + " background: url('imagem/porn.jpg') no-repeat center center fixed;\n" + " background-size: cover;\n" + " background:\n" + " background-size: 100% 100%;\n" + " background-repeat: repeat;\n" + " background-color: #101110;\n" + " }\n" + "</style>\n" + "<body>\n" + " <section class=\"dashboard-header\">\n" + " <div class=\"container-fluid\">\n" + " <div class=\"row\">\n\n" + " <div class=\"statistics col-lg-3 col-s12\">\n" + " <div class=\"statistic d-flex align-items-center bg-white has-shadow\">\n" + " <div class=\"icon bg-green\"><i style=\"padding-top: 25%;\" class=\"fa fa-check\"></i></div>\n" + " <div class=\"text\"><strong id=\"cLive\">0</strong><br><small>Approved</small></div>\n" + " </div>\n" + " <div class=\"statistic d-flex align-items-center bg-white has-shadow\">\n" + " <div class=\"icon bg-red\"><i style=\"padding-top: 25%;\" class=\"fa fa-close\"></i></div>\n" + " <div class=\"text\"><strong id=\"cDie\">0</strong><br><small>Reejected</small></div>\n" + " </div>\n" + " <div class=\"statistic d-flex align-items-center bg-white has-shadow\">\n" + " <div class=\"icon bg-info\"><i style=\"padding-top: 25%;\" class=\"fa fa-battery-full\"></i></div>\n" + " <div class=\"text\"><strong id=\"carregadas\">0</strong><br><small>Loaded</small></div>\n" + " </div>\n" + " <div class=\"statistic d-flex align-items-center bg-white has-shadow\">\n" + " <div class=\"icon bg-primary\"><i style=\"padding-top: 25%;\" class=\"fa fa-handshake-o \"></i></div>\n" + " <div class=\"text\"><strong id=\"total\">0</strong><br><small>Tested</small></div>\n" + " </div></div>\n" + " \n" + " <div class=\"statistics col-lg-9 col-12\">\n" + " <div class=\"statistic bg-white has-shadow\">\n" + " <blockquote class=\"blockquote mb-0 card-body\">\n" + " <center>\n" + " <textarea rows=\"7\" placeholder=\"ᏆhᎬ ᏆᎬᏟhᏒᎥm | ILGA Gate, 𝑮𝑨𝑻𝑬 𝑺𝑻𝑹𝑰𝑷𝑬\" class=\"form-control\" id=\"list\" style=\"resize: none; outline: 0; text-align: center; width: 100%;\"></textarea>\n" + " <br><div class=\"progress\">\n" + " <div role=\"progressbar\" id=\"progreso\" style=\"height: 100%; border: solid 1px purpul;\" aria-valuenow=\"70\" aria-valuemin=\"0\" aria-valuemax=\"100\" class=\"progress-bar bg-primary\"></div>\n" + " </div><br>\n" + " \n" + " <button id=\"testar\" style=\"float: left; width: 48%;\" class=\"btn btn-primary\">\n" + " <i class=\"fa fa-play\"></i> Start</button>\n" + " \n" + " <button disabled=\"\" id=\"stop\" style=\"float: left; width: 48%; margin-left: 3%;\" class=\"btn btn-danger\"><i class=\"fa fa-pause\"></i> Pause</button><br>\n" + " </center>\n" + " </blockquote>\n" + " </div>\n" + " </div>\n\n" + "<div style=\"margin-top: 10px;\" class=\"statistics col-lg-20 col-12\">\n" + " <div class=\"articles card\">\n" + " <div class=\"card-close\">\n" + " <div class=\"dropdown\">\n" + " \n" + " <span class=\"pull-right\">\n" + " <button type=\"button\" class=\"btn btn-xs btn-danger\" onclick=\"document.getElementById('lives').innerHTML = ''\"><i class=\"fa fa-close\"> Clear </i></font></button>\n" + " </span>\n" + " </div>\n" + " </div>\n\n" + " <div class=\"card-header d-flex align-items-center\">\n" + " <h2 class=\"h3\">Approved <i class=\"fa fa-check\"></i></h2>\n" + " \n" + " </div>\n\n" + " <div class=\"card-body no-padding bg-white\">\n" + " <table class=\"table table-bordered\">\n" + " <thead>\n" + " <tr>\n" + " <th scope=\"col\">#</th>\n" + " <th scope=\"col\">Card</th>\n" + " <th scope=\"col\">Information</th>\n" + " <th scope=\"col\">Gate</th>\n" + " <th scope=\"col\">Result</th>\n" + " <th scope=\"col\">Copyright</th>\n\n" + " </tr>\n" + " </thead>\n" + " <tbody>\n" + " </tr>\n" + " <tbody id=\"lives\">\n" + " \n" + " \n" + " </tbody>\n" + " </table>\n" + " </div>\n" + " </div>\n" + " </div>\n" + " </div>\n" + " <div style=\"margin-top: 10px;\" class=\"statistics col-lg-15 col-15\">\n" + " <div class=\"articles card\">\n" + " <div class=\"card-close\">\n" + " <div class=\"dropdown\">\n" + " \n" + " <span class=\"pull-right\">\n" + " <button type=\"button\" class=\"btn btn-xs btn-danger\" onclick=\"document.getElementById('employe').innerHTML = ''\"><i class=\"fa fa-close\"> Clear </i></font></button>\n" + " </span>\n" + " </div>\n" + " </div>\n\n" + " <div class=\"card-header d-flex align-items-center\">\n" + " <h2 class=\"h3\">Rejected <i class=\"fa fa-close\"></i></h2>\n" + " \n" + " </div>\n" + " <div class=\"card-body no-padding bg-transparent\">\n" + " <table class=\"table table-bordered\">\n" + " <thead>\n" + " <tr>\n" + " <th scope=\"col\">#</th>\n" + " <th scope=\"col\">Card</th>\n" + " <th scope=\"col\">Information</th>\n" + " <th scope=\"col\">Gate</th> \n" + " <th scope=\"col\">Result</th>\n" + " <th scope=\"col\">Copyright</th>\n" + " </tr>\n" + " </thead>\n" + " <tbody>\n" + " </tr>\n" + " <tbody id=\"employe\">\n" + " \n" + " \n" + " </tbody>\n" + " </table>\n" + " </div class=\"bg-white\">\n" + " </div class=\"bg-white\">\n" + " </div class=\"bg-white\">\n" + " </div class=\"bg-white\">\n" + " \n" + " </div class=\"bg-white\">\n\n" + " </div class=\"bg-white\">\n\n" + " </section>\n\n\n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " <script src=\"arquivos/jquery.min.js(1)\"></script>\n" + " <script src=\"arquivos/popper.min.js\"> </script>\n" + " <script src=\"arquivos/bootstrap.min.js\"></script>\n" + " <script src=\"arquivos/jquery.cookie.js\"> </script>\n" + " <script src=\"arquivos/Chart.min.js\"></script>\n" + " <script src=\"arquivos/jquery.validate.min.js\"></script>\n" + " <script src=\"arquivos/charts-home.js\"></script>\n" + " \n\n" + " <script src=\"arquivos/messenger-theme-flat.js\"> </script>\n" + " <script src=\"arquivos/home-premium.js\"> </script>\n" + " \n" + " <script src=\"arquivos/front.js\"></script>\n" + " "; final Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE | Pattern.DOTALL); final Matcher matcher = pattern.matcher(string); while (matcher.find()) { System.out.println("Full match: " + matcher.group(0)); for (int i = 1; i <= matcher.groupCount(); i++) { System.out.println("Group " + i + ": " + matcher.group(i)); } } } }

Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Java, please visit: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html