Regular Expressions 101

Save & Share

  • Regex Version: ver. 1
  • Update Regex
    ctrl+⇧+s
  • Save new Regex
    ctrl+s
  • Add to Community Library

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

/
/
gm

Test String

Code Generator

Generated Code

// include the latest version of the regex crate in your Cargo.toml extern crate regex; use regex::Regex; fn main() { let regex = Regex::new(r"(?m)(?x)(<html[\S\s]*?<\/h1>)(*SKIP)(*F)|(<p[^>]*>[\S\s]*?uses\]<\/p>)(*SKIP)(*F)|(<[\S\s]*?>)(*SKIP)(*F)|(E-mail)(*SKIP)(*F)|(<h6[^<>]*>.*?<\/h6>)(*SKIP)(*F)|(A-Z)(*SKIP)(*F)|(<a\s[^>]*href.*?<\/a>)(*SKIP)(*F)|(2009-2024)(*SKIP)(*F)|(<style[\S\s]*?<\/style>)(*SKIP)(*F)|(<script[\S\s]*?<\/script>)(*SKIP)(*F)|\w+\(").unwrap(); let string = "<!DOCTYPE html> <html lang=\"en\"> <head> <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"> <META name=\"viewport\" content=\"width=device-width, initial-scale=1\"> <title>Homeopathic medicine, Homeopathic remedies, ACONITUM NAPELLUS</title> <META name=\"description\" content=\"ACONITUM NAPELLUS\"> <META name=\"keywords\" content=\"Homeopathic medicine Bangalore, Homeopathic remedies Bangalore, ACONITUM NAPELLUS\"> <META name=\"robots\" content=\"index, follow\" /> <META name=\"google-site-verification\" content=\"B5jrpKjfHEj--_J-rT51c3CG8zg1sY_ZRQAbqQ1oN5Q\"> <link href=\"css/style.css\" rel=\"stylesheet\" type=\"text/css\" media=\"all\"> <link href=\"https://www.cure4incurables.in/css/bootstrap.min.css\" rel=\"stylesheet\"> <link href=\"https://www.cure4incurables.in/css/style1.css\" rel=\"stylesheet\"> <link href=\"css/style.css\" rel=\"stylesheet\" type=\"text/css\" media=\"all\"> <link rel=\"stylesheet\" type=\"text/css\" href=\"engine1/style.css\" media=\"screen\"> <link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css\"> </head> <body style=\"color: rgb(0, 0, 0);\" alink=\"#ee0000\" link=\"#0000ee\" vlink=\"#551a8b\"> <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --><!-- Bootstrap --><!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --><!-- WARNING: Respond.js doesn't work if you view the page via file:// --><!--[if lt IE 9]> <script src=\"https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js\"></script> <script src=\"https://oss.maxcdn.com/respond/1.4.2/respond.min.js\"></script> <![endif]-->&nbsp; <!-- Start WOWSlider.com HEAD section --><!-- End WOWSlider.com HEAD section --><!--body wrapper--> <div class=\"container\"> <div class=\"container1\"> <div class=\"sticky\"> Bangalore based polyclinic offering treatments in modern medicine, homoeopathy, ayurveda, naturopathy, hypnotherapy, healing and meditation, etc. </div> <!--navigation --><nav class=\"navbar navbar-default\"><!-- Brand and toggle get grouped for better mobile display --> <div class=\"row\"> <div class=\"navbar-header\"><!-- a class=\"navbar-brand\" href=\"index.html\" --><!-- Collect the nav links, forms, and other content for toggling --><a class=\"navbar-brand\" href=\"index.html\" style=\"text-decoration: none; color: rgb(46, 150, 226);\"><img src=\"https://www.cure4incurables.in/images/logo.png\" alt=\"Logo\" class=\"responsive\"></a></div><!-- div class=\"collapse navbar-collapse\" id=\"bs-example-navbar-collapse-1\" --> <!-- div class=\"container\" --> <div><div class=\"translate\" id=\"google_translate_element\" style=\"text-align: right; margin-right: 0.2in;\"><p class=\"translate\" style=\"font-size: 15px; color: black; line-height: 18px; font-style: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; background-color: transparent; font-family: Verdana; text-align: right;\"><strong><span style=\"color: blue;\">ಭಾಷೆ ಬದಲಾಯಿಸಲು ಕೆಳಗೆ ಕ್ಲಿಕ್ ಮಾಡಿ:</span><br><span style=\"color: navy;\">भाषा बदलने के लिए, नीचे क्लिक करें:-</span></strong> </p></div> <ul class=\"topnav\" id=\"myTopnav\" style=\"padding: 0px; margin-left: 0.2in; margin-right: 0.2in; list-style-type: none; list-style-image: none; list-style-position: outside; vertical-align: middle; font-family: &quot;Segoe UI&quot;; font-size: 16px; background-color: #87cefa;\"> <li class=\"links\"><a style=\"color: black;\" href=\"#\">Links:</a></li> <li class=\"links\"><a style=\"color: black;\" href=\"index.html\">Home</a></li> <li class=\"links\"><a style=\"color: black;\" href=\"About-a-cure-for-incurables-clinic.html\">About Us</a></li> <li class=\"links\"><a style=\"color: black;\" href=\"Our-Services.html\">Our Services</a></li> <li class=\"links\"> <a style=\"color: black;\" href=\"homeopathy-treatment.html\">Homeopathy</a></li> <li class=\"links\"><a style=\"color: black;\" href=\"testimonials.html\">Testimonials</a></li> <li class=\"links\"><a style=\"color: black;\" href=\"Biz-Offers.html\">Biz Offers</a></li> <li class=\"links\"><a style=\"color: black;\" href=\"Contact-Us.html\">Contact Us</a></li> <li class=\"links\"><a style=\"color: black;\" href=\"enquiry.html\">Enquiry</a></li> <!--</li> --><li class=\"icon\"> <a style=\"margin-top: -5px;\" href=\"#\" id=\"toggle\"><big><big>&#x25BC;</big></big></a></li></ul></div></div> </nav><!-- /.navbar-collapse --><!-- /.container-fluid --><!-- /.nav --><!--Header Ends--><!--body content--> <div style=\"\"><!--slider--> <div id=\"carousel-example-generic\" class=\"carousel slide\" data-ride=\"carousel\"><!-- Indicators --><!-- Wrapper for slides --> <div class=\"carousel-inner\"></div> <!-- Controls --></div> <!-- end slider--><br> <!-- div id=\"container\" --> <div id=\"right\"><!-- div class=\"row add-top\" --><!-- div class=\"col-md-9 col-sm-9\" --><!-- div class=\"bodycont\" --><!-- div class=\"body-right\" --><!-- div class=\"bodycont\" --> <div class=\"quickcontact\"><!-- div class=\"body-right\" --><!-- div class=\"body-right-title\" --> <div class=\"row add-top\"> <div class=\"col-md-9 col-sm-9\"> <div class=\"bodycont\"> <h1>ACONITUM NAPELLUS [Acon]</h1> <p style=\"color: black; font-family: Verdana,sans-serif; font-size: 18px; font-style: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; display: inline ! important; float: none;\">ACONITUM NAPELLUS uses [Acon uses]</p> <p class=MsoNormal><span style='font-size:13.5pt;line-height:115%;font-family: \"Verdana\",\"sans-serif\";color:black;mso-themecolor:text1'>Note: Wherever it is found, &quot;&lt;&quot; denotes aggravation (worse by), &quot;&gt;&quot; denotes amelioration (better by), &quot;&lt;-&gt;&quot; denotes alternation (alternates with) and A/F is an abbreviation of, &quot;Ailments from&quot;</span> </p> <div style=\"margin-bottom:-15px;width:100%;background-color:#EBF4FB;\"> <p class=MsoNormal style='margin-bottom:12.0pt;line-height:normal'><span style='font-size:13.5pt;font-family:\"Verdana\",\"sans-serif\";mso-fareast-font-family: \"Times New Roman\";mso-bidi-font-family:\"Times New Roman\";color:#075296'>Terror, anxiety, agonizing fear, restless, excited, nervous, impatient<br><br> Sudden, violently acute, painful effects. Congestions. Inflammation. Haemorrhages<br><br> Sticking, tearing pains with numbness. Burning thirst. High fever</span></p> </div> <div class=\"container\"> <div class=\"left\"> <p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height: normal'><b><span style='font-size:13.5pt;font-family:\"Verdana\",\"sans-serif\"; mso-fareast-font-family:\"Times New Roman\";mso-bidi-font-family:\"Times New Roman\"; color:red'>REMEDY RELATIONSHIPS</span></b> </p> </div> <div class=\"right\"> <p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height: normal'><b><span style='font-size:13.5pt;font-family:\"Verdana\",\"sans-serif\"; mso-fareast-font-family:\"Times New Roman\";mso-bidi-font-family:\"Times New Roman\"; color:black'>Complements: </span></b><span style='font-size:13.5pt; font-family:\"Verdana\",\"sans-serif\";mso-fareast-font-family:\"Times New Roman\"; mso-bidi-font-family:\"Times New Roman\";color:black'>Arn, Coff, Sulph<br> <br> <b>Follows Well: </b>Ars, Bell, Bry, Calc, Hep, Ip, Lyc, Merc, Nux-v, Phos, Puls, Rhus, Sep, Spong<br> <br> <b>Compare: </b>Bell, Cann-i, Cham, Cocc, Con, Dulc<br> <br> <b>Antidoted By: </b>Acet-ac, Cham, Cimic, Coff, Nux-v, Par, Petr, Sep, Sulph(Brimstone)<br> <br> <b>It Antidotes: </b>Arn, Aspin, Astac, Bell, Bry, Cact, Canth, Cham, Chel, Cit-v, Coff, Croc, Dol, Glon, Graph, Kalm, Kreos, Lyc, Merc-p, Mez, Morph, Nux-v, Petr, Sep, Sol, Spong, Stry, Sulph, Ther, Verat, Vib-p</span> </p> </td> </tr> </table> </div> </div> </div> </div> <div class=\"col-md-3 col-sm-3\"> <div class=\"bodycont\"> <div class=\"quickcontact\"> <h6>Specializations</h6> <ul class=\"list-unstyled\"> <li><a href=\"modern-medicine.html\" title=\"Modern Medicine| Modern Medicine Bangalore\">Modern Medicine</a></li> <li> <a href=\"homeopathy-treatment.html\" title=\"Homeopathy treatment| Homeopathy treatment Bangalore\">Homeopathy treatment</a> </li> <li><a href=\"homeopathy-doctor.html\" title=\"Homeopathy Doctor| Homeopathy Doctor Bangalore\">Homeopathy Doctor</a></li> <li> <a href=\"6_Cancer.html\" title=\"Homeopathy Cancer| Homeopathy Cancer Bangalore\">Cancer</a></li> <li><a href=\"hiv-aids.html\" title=\"Homeopathy HIV AIDS| Homeopathy HIV AIDS Bangalore\">HIV / AIDS</a></li> <li><a href=\"ayurveda.html\" title=\"Ayurveda| Ayurveda Bangalore\">Ayurveda</a></li> <li><a href=\"naturopathy.html\" title=\"Naturopathy| Naturopathy Bangalore\">Naturopathy</a> </li> <li><a href=\"hypnotherapy.html\" title=\"Hypnotherapy| Hypnotherapy Bangalore\">Hypnotherapy</a> </li> <li><a href=\"Meditation.html\" title=\"Meditation| Meditation Bangalore\">Meditation</a></li> </ul> <div class=\"quickcontact\"> <h6>Remedies A-Z</h6> </div> <div style=\"margin: 2px; overflow: scroll; height: 275px; padding-top: 2px;\"><!-- div id=\"collapse1\" class=\"panel-collapse collapse\" --> <ul class=\"list-unstyled\"> <li><a href=\"Abies-Canadensis.html\">Abies Canadensis</a></li> <li><a href=\"Abies-Nigra.html\">Abies Nigra</a></li> <li><a href=\"Abrotanum.html\">Abrotanum</a></li> <li><a href=\"Acalypha-Indica.html\">Acalypha Indica</a></li> <li><a href=\"Aceticum-Acidum.html\">Aceticum Acidum</a></li> <li><a href=\"ACONITUM-NAPELLUS.html\">Aconitum Napellus</a></li> </ul> </div> <div class=\"quickcontact\"> <h6>Diseases &amp; Conditions</h6> </div> <div style=\"margin: 2px; overflow: scroll; height: 275px; padding-top: 2px;\"> <ul class=\"list-unstyled\"> <li><a href=\"acne.html\">Acne or Pimples</a></li> <li><a href=\"pimples.htm\">Zits</a></li> </ul> </div> </div> </div> </div> </div> </div> </div> <!-- end wrapper--><!--body content ends--><!--footer--> <div class=\"clear\"></div> <br><footer style=\"width: 100%; height: auto;\" class=\"panel-footer footer add-top\"> <div style=\"width: 100%; height: auto;\" class=\"container\"><div style=\"width: 100%; height: auto; background-color: transparent;\" class=\"col-md-12 col-sm-12\"><a href=\"index.html\"> Home</a> |<a href=\"About-a-cure-for-incurables-clinic.html\"> About Us</a>|<a href=\"101_Dr.Ramanand-j-v.html\"> Dr Ramaanand</a> |<a href=\"Our-Services.html\"> Our Services</a>| <a href=\"homeopathy-doctor.html\"> Homeopathy Doctor</a> | <a href=\"Homeopathy-clinic.html\"> Homeopathy Clinic</a> |<a href=\"testimonials.html\"> Testimonials</a> |<a href=\"homoeopathy.html\"> Homoeopathy</a> | <a href=\"defending-homeopathy.html\"> Defending Homeopathy</a> |<a href=\"Biz-Offers.html\"> Biz offers</a> |<a href=\"Contact-Us.html\"> Contact Us</a></div> </div> </footer> <div class=\"footer-btm\"> <div class=\"container\"> <div class=\"col-md-12 col-sm-12 text-center\"> A Cure for Incurables Clinic &copy; 2009-2024 | All Rights Reserved.</div> </div> </div> <!-- to top--><a href=\"#\" class=\"cd-top\">Top</a> <button class=\"button-top\"><i class=\"fa fa-chevron-up\"></i></button> <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js\"></script> <!-- Include all compiled plugins (below), or include individual files as needed --> <script src=\"js/bootstrap.min.js\"></script> <script src=\"js/backtotop.js\"></script> <script type=\"text/javascript\" src=\"js/function.js\"></script> <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js\"></script> <style type=\"text/css\"> p.translate { display: none;} @media only screen and (min-width : 320px) and (max-width : 861px){ p.translate { display: inline; } } ul.topnav { list-style-type: none; margin: 0; padding: 6px; overflow: hidden; background-color: #87cefa; } ul.topnav li { float: left; } ul.topnav li a { display: inline-block; color: #f2f2f2; text-align: center; padding: 0px 3px; text-decoration: none; transition: 0.3s; font-size: 16px; } ul.topnav li a:hover { background-color: #0000FF; color: white !important; } ul.topnav li.icon { display: none; } @media screen and (max-width:1180px) { ul.topnav li:not(:first-child) { display: none; } ul.topnav li.icon { float: left; display: inline-block; } } @media screen and (max-width:680px) { div.translate { margin-top: 3%; } ul.topnav.responsive { position: relative; } ul.topnav.responsive li.icon { position: absolute; right: 0; top: 0; } ul.topnav.responsive li { float: none; display: inline; } ul.topnav.responsive li a { display: block; text-align: left; } } .button-top { position: fixed; bottom: 20px; right: 20px; z-index: 100; width: 40px; height: 40px; border: 0; border-radius: 2px; box-shadow: none; background: rgba(0, 196, 242, 0.3); color: white; font-size: 26px; line-height: 20px; text-align: center; cursor: pointer; } .button-top { ...previous code pointer-events: none; opacity: 0; transition: opacity .18s ease; } .button-top-visible { opacity: 1; pointer-events: auto; } ul.list-unstyled li { font-size: 16px; } .table_wrapper { display: block; width: max-content; max-width: 100%; overflow: auto; resize: horizontal; border: 0px solid black; } @media screen and (max-width: 600px) { p.translate { display: inline; } } .container { display: flex; } .container > div {} } .left { width: 150px; border-width:1px; border-style:solid; border-color:lightblue; padding-top:10px; } .right { width: 150px; border-width:1px; border-style:solid; border-color:lightblue; } @media (max-width: 480px) { .left { width: 150px; border-width:1px; border-style:solid; border-color:lightblue; padding-top:10px; } .right { width: 145px; border-top:1px solid lightblue; li { margin-left: -30px; } li div.marginleft { margin-left: -6px; } } } @media (min-width: 481px) and (max-width: 767px) { .left { width: 175px; border-width:1px; border-style:solid; border-color:lightblue; padding-top:10px; } .right { width: 250px; border-width:1px; border-style:solid; border-color:lightblue; } } @media (min-width: 768px) and (max-width: 1024px) { .left { width: 180px; border-width:1px; border-style:solid; border-color:lightblue; padding-top:10px; } .right { width: 360px; border-width:1px; border-style:solid; border-color:lightblue; } } @media (min-width: 1025px) and (max-width: 1280px) { .left { width: 180px; border-width:1px; border-style:solid; border-color:lightblue; padding-top:10px; } .right { width: 520px; border-width:1px; border-style:solid; border-color:lightblue; } } @media (min-width: 1281px) { .left { width: 180px; border-width:1px; border-style:solid; border-color:lightblue; padding-top:10px; } .right { width: 560px; border-width:1px; border-style:solid; border-color:lightblue; margin-top:0px; } } </style> <script> $(function() { $('.links').on(\"click\", function() { $(\"#myTopnav\").removeClass(\"responsive\"); }); $(\"#toggle\").on(\"click\", function() { const $nav = $(\"#myTopnav\"); $nav.toggleClass(\"responsive\"); $(this).html( $nav.hasClass(\"responsive\") ? \"<big><big>&#x2715;</big></big>\" : \"<big><big>&#x25BC;</big></big>\" ) }); }); </script> <div id=\"google_translate_element\"></div> <script type=\"text/javascript\"> function googleTranslateElementInit() { new google.translate.TranslateElement({pageLanguage: 'en'}, 'google_translate_element'); } </script> <script> jQuery(function ($) { var $window = $(window); var $buttonTop = $('.button-top'); $buttonTop.on('click', function () { $('html, body').animate({ scrollTop: 0, }, 400); }); $window.on('scroll', function () { if ($window.scrollTop() > 300) { // 300 is our threshold in pixels $buttonTop.addClass('button-top-visible'); } else { $buttonTop.removeClass('button-top-visible'); } }); }); </script> <script type=\"text/javascript\" src=\"https://translate.google.com/translate_a/element.js? cb=googleTranslateElementInit\"> </script> <script type=\"text/javascript\" src=\"engine1/jquery.js\"></script> </div> </div> </div> </div> </div> </div> </body> </html>"; // result will be an iterator over tuples containing the start and end indices for each match in the string let result = regex.captures_iter(string); for mat in result { println!("{:?}", mat); } }

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 Rust, please visit: https://docs.rs/regex/latest/regex/