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
No Match

r"
"
gm

Test String

Code Generator

Generated Code

package main import ( "regexp" "fmt" ) func main() { var re = regexp.MustCompile(`(?m)&#8212;</span> (.+?) <a.+?href=\"(.+?)\">CH(.+?)<.+?/>(.+?) <`) var str = ` <!DOCTYPE html> <html lang="en-US"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>HDSTREAMS.CLUB &#8211; Watch Soccer, NBA, NFL, Racing and Fighting Games Live</title> <link rel='dns-prefetch' href='//fonts.googleapis.com' /> <link rel='dns-prefetch' href='//s.w.org' /> <link rel="alternate" type="application/rss+xml" title="HDSTREAMS.CLUB &raquo; Feed" href="http://hdstreams.club/feed/" /> <link rel="alternate" type="application/rss+xml" title="HDSTREAMS.CLUB &raquo; Comments Feed" href="http://hdstreams.club/comments/feed/" /> <script type="text/javascript"> window._wpemojiSettings = {"baseUrl":"https:\/\/s.w.org\/images\/core\/emoji\/12.0.0-1\/72x72\/","ext":".png","svgUrl":"https:\/\/s.w.org\/images\/core\/emoji\/12.0.0-1\/svg\/","svgExt":".svg","source":{"concatemoji":"http:\/\/hdstreams.club\/wp-includes\/js\/wp-emoji-release.min.js?ver=5.3.2"}}; !function(e,a,t){var r,n,o,i,p=a.createElement("canvas"),s=p.getContext&&p.getContext("2d");function c(e,t){var a=String.fromCharCode;s.clearRect(0,0,p.width,p.height),s.fillText(a.apply(this,e),0,0);var r=p.toDataURL();return s.clearRect(0,0,p.width,p.height),s.fillText(a.apply(this,t),0,0),r===p.toDataURL()}function l(e){if(!s||!s.fillText)return!1;switch(s.textBaseline="top",s.font="600 32px Arial",e){case"flag":return!c([127987,65039,8205,9895,65039],[127987,65039,8203,9895,65039])&&(!c([55356,56826,55356,56819],[55356,56826,8203,55356,56819])&&!c([55356,57332,56128,56423,56128,56418,56128,56421,56128,56430,56128,56423,56128,56447],[55356,57332,8203,56128,56423,8203,56128,56418,8203,56128,56421,8203,56128,56430,8203,56128,56423,8203,56128,56447]));case"emoji":return!c([55357,56424,55356,57342,8205,55358,56605,8205,55357,56424,55356,57340],[55357,56424,55356,57342,8203,55358,56605,8203,55357,56424,55356,57340])}return!1}function d(e){var t=a.createElement("script");t.src=e,t.defer=t.type="text/javascript",a.getElementsByTagName("head")[0].appendChild(t)}for(i=Array("flag","emoji"),t.supports={everything:!0,everythingExceptFlag:!0},o=0;o<i.length;o++)t.supports[i[o]]=l(i[o]),t.supports.everything=t.supports.everything&&t.supports[i[o]],"flag"!==i[o]&&(t.supports.everythingExceptFlag=t.supports.everythingExceptFlag&&t.supports[i[o]]);t.supports.everythingExceptFlag=t.supports.everythingExceptFlag&&!t.supports.flag,t.DOMReady=!1,t.readyCallback=function(){t.DOMReady=!0},t.supports.everything||(n=function(){t.readyCallback()},a.addEventListener?(a.addEventListener("DOMContentLoaded",n,!1),e.addEventListener("load",n,!1)):(e.attachEvent("onload",n),a.attachEvent("onreadystatechange",function(){"complete"===a.readyState&&t.readyCallback()})),(r=t.source||{}).concatemoji?d(r.concatemoji):r.wpemoji&&r.twemoji&&(d(r.twemoji),d(r.wpemoji)))}(window,document,window._wpemojiSettings); </script> <style type="text/css"> img.wp-smiley, img.emoji { display: inline !important; border: none !important; box-shadow: none !important; height: 1em !important; width: 1em !important; margin: 0 .07em !important; vertical-align: -0.1em !important; background: none !important; padding: 0 !important; } </style> <link rel='stylesheet' id='wp-block-library-css' href='http://hdstreams.club/wp-includes/css/dist/block-library/style.min.css?ver=5.3.2' type='text/css' media='all' /> <link rel='stylesheet' id='pkhosting-fonts-css' href='//fonts.googleapis.com/css?family=Playball%3A400%2C700%2C900%7CPoppins%3A300%2C400%2C500%2C600%2C700%7CLato%3A100%2C100i%2C300%2C300i%2C400%2C400i%2C700%2C700i%2C900%2C900i%7CMontserrat%3A400%2C700&#038;subset=latin%2Clatin-ext' type='text/css' media='all' /> <link rel='stylesheet' id='bootstrap_style_min-css' href='http://hdstreams.club/wp-content/themes/pkhosting/css/bootstrap.min.css?ver=5.3.2' type='text/css' media='all' /> <link rel='stylesheet' id='pkhosting-style-css' href='http://hdstreams.club/wp-content/themes/pkhosting/style.css?ver=5.3.2' type='text/css' media='all' /> <link rel='stylesheet' id='font-awesome-min-css' href='http://hdstreams.club/wp-content/themes/pkhosting/css/font-awesome.min.css?ver=5.3.2' type='text/css' media='all' /> <link rel='stylesheet' id='animate_min-css' href='http://hdstreams.club/wp-content/themes/pkhosting/css/animate.min.css?ver=5.3.2' type='text/css' media='all' /> <script type='text/javascript' src='http://hdstreams.club/wp-includes/js/jquery/jquery.js?ver=1.12.4-wp'></script> <script type='text/javascript' src='http://hdstreams.club/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.4.1'></script> <script type='text/javascript' src='http://hdstreams.club/wp-content/themes/pkhosting/js/bootstrap.js?ver=5.3.2'></script> <script type='text/javascript' src='http://hdstreams.club/wp-content/themes/pkhosting/js/jquery.smartmenus.min.js?ver=5.3.2'></script> <link rel='https://api.w.org/' href='http://hdstreams.club/wp-json/' /> <link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://hdstreams.club/xmlrpc.php?rsd" /> <link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://hdstreams.club/wp-includes/wlwmanifest.xml" /> <meta name="generator" content="WordPress 5.3.2" /> <link rel="canonical" href="http://hdstreams.club/" /> <link rel='shortlink' href='http://hdstreams.club/' /> <link rel="alternate" type="application/json+oembed" href="http://hdstreams.club/wp-json/oembed/1.0/embed?url=http%3A%2F%2Fhdstreams.club%2F" /> <link rel="alternate" type="text/xml+oembed" href="http://hdstreams.club/wp-json/oembed/1.0/embed?url=http%3A%2F%2Fhdstreams.club%2F&#038;format=xml" /> <style type="text/css"> </style> <style type="text/css">.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style><script type="text/javascript">var _gaq = _gaq || [];_gaq.push(["_setAccount", "UA-133782126-8"]);_gaq.push(["_trackPageview"]);(function() {var ga = document.createElement("script"); ga.type = "text/javascript"; ga.async = true;ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ga, s);})();</script></head> <body class="home page-template-default page page-id-5"> <div class="wrapper"> <header> <div class="clearfix"></div> <div class="pk-main-nav"> <div class="container"> <div class="row"> <div class="col-xs-12 col-sm-3"> <div class="navbar-header"> <!-- Logo --> <a class="navbar-brand" href="http://hdstreams.club/"><span class="site-title">HDSTREAMS.CLUB</span> <br> <span class="site-description">Watch Soccer, NBA, NFL, Racing and Fighting Games Live</span> </a> <!-- Logo --> </div> </div> <div class="col-xs-12 col-sm-9 main-menu" > <nav class="navbar navbar-default navbar-static-top navbar-wp"> <!-- navbar-toggle --> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-wp"> <span class="sr-only"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <!-- /navbar-toggle --> <!-- Navigation --> <div class="collapse navbar-collapse" id="navbar-wp"> </div> <!-- /Navigation --> </nav> </div> </div> </div> </div> </header> <!-- #masthead --> <main id="content"> <div class="container"> <div class="row"> <div class="col-lg-9 col-md-9"> <div class="single-content-container"> <div class="row"> <div class="col-lg-12"> <div class="page-content"> <h1>Today&#8217;s Schedule</h1> <h1><span style="text-decoration: underline;"><span style="color: #ff0000; text-decoration: underline;">Saturday 28 </span></span><span style="text-decoration: underline; color: #ff0000;">December 2019</span></h1> <h2><span style="text-decoration: underline; color: #993300;">Schedule Time is IST 05:30</span></h2> <p>01:15 <span style="color: #0000ff;">Soccer &#8212;</span> Wolves Vs Manchester City NBCSN <a href="http://hdstreams.club/hd/ch1.php">CH1</a> EN<br />01:15 <span style="color: #0000ff;">Soccer &#8212;</span> Dundee United Vs Dundee FC BT Sport 2 <a href="http://hdstreams.club/hd/ch2.php">CH2</a> EN<br />03:30 <span style="color: #0000ff;">NBA &#8212;</span> Cleveland Cavaliers Vs Boston Celtics NBA TV <a href="http://hdstreams.club/hd/ch4.php">CH4</a> EN<br />05:30 <span style="color: #0000ff;">NBA &#8212;</span> Oklahoma City Thunder Vs Charlotte Hornets FOX SPORTS OKLAHOMA <a href="http://hdstreams.club/hd/ch3.php">CH3</a> EN<br />05:30 <span style="color: #0000ff;">NBA &#8212;</span> Philadelphia 76ers Vs Orlando Magic NBA TV <a href="http://hdstreams.club/hd/ch4.php">CH4</a> EN<br />06:00 <span style="color: #0000ff;">NBA &#8212;</span> Milwaukee Bucks Vs Atlanta Hawks FOX SPORTS WISCONSIN <a href="http://hdstreams.club/hd/ch5.php">CH5</a> EN<br />06:30 <span style="color: #0000ff;">NBA &#8212;</span> Indiana Pacers Vs Miami Heat FOX SPORTS SUN <a href="http://hdstreams.club/hd/ch6.php">CH6</a> EN<br />09:00 <span style="color: #0000ff;">NBA &#8212;</span> Phoenix Suns Vs Golden State Warriors NBA TV <a href="http://hdstreams.club/hd/ch4.php">CH4</a> EN<br />18:00 <span style="color: #0000ff;">Soccer &#8212;</span> Brighton Vs Bournemouth NBCSN <a href="http://hdstreams.club/hd/ch2.php">CH2</a> EN<br />20:30 <span style="color: #0000ff;">Soccer &#8212;</span> Newcastle Vs Everton NBCSN <a href="http://hdstreams.club/hd/ch2.php">CH2</a> EN<br />20:30 <span style="color: #0000ff;">Soccer &#8212;</span> Southampton Vs Crystal Palace SuperSport 5 <a href="http://hdstreams.club/hd/ch5.php">CH5</a> EN<br />20:30 <span style="color: #0000ff;">Soccer &#8212;</span> Watford Vs Aston Villa SuperSport 4 <a href="http://hdstreams.club/hd/ch4.php">CH4</a> EN<br />23:00 <span style="color: #0000ff;">Soccer &#8212;</span> Norwich Vs Tottenham Sky Sports Main Event <a href="http://hdstreams.club/hd/ch6.php">CH6</a> EN<br />23:00 <span style="color: #0000ff;">Soccer &#8212;</span> West Ham Vs Leicester SuperSport 3 <a href="http://hdstreams.club/hd/ch3.php">CH3</a> EN</p> <h1><span style="text-decoration: underline;"><span style="color: #ff0000; text-decoration: underline;">Sunday 29 </span></span><span style="text-decoration: underline; color: #ff0000;">December 2019</span></h1> <h2><span style="text-decoration: underline; color: #993300;">Schedule Time is IST 05:30</span></h2> <p>01:15 <span style="color: #0000ff;">Soccer &#8212;</span> Burnley Vs Manchester United BT Sport 1 <a href="http://hdstreams.club/hd/ch1.php">CH1</a> EN<br />03:30 <span style="color: #0000ff;">NBA &#8212;</span> Memphis Grizzlies Vs Denver Nuggets FOX SPORTS SOUTHEAST &#8211; MEMPHIS <a href="http://hdstreams.club/hd/ch7.php">CH7</a> EN<br />05:30 <span style="color: #0000ff;">NBA &#8212;</span> Toronto Raptors Vs Boston Celtics TSN1 <a href="http://hdstreams.club/hd/ch8.php">CH8</a> EN<br />05:30 <span style="color: #0000ff;">NBA &#8212;</span> Indiana Pacers Vs New Orleans Pelicans FOX SPORTS NEW ORLEANS <a href="http://hdstreams.club/hd/ch9.php">CH9</a> EN<br />06:30 <span style="color: #0000ff;">NBA &#8212;</span> Philadelphia 76ers Vs Miami Heat NBA TV CANADA <a href="http://hdstreams.club/hd/ch10.php">CH10</a> EN<br />06:30 <span style="color: #0000ff;">NBA &#8212;</span> New York Knicks Vs Washington Wizards MSG <a href="http://hdstreams.club/hd/ch11.php">CH11</a> EN<br />06:30 <span style="color: #0000ff;">NBA &#8212;</span> Atlanta Hawks Vs Chicago Bulls NBC SPORTS CHICAGO <a href="http://hdstreams.club/hd/ch12.php">CH12</a> EN<br />06:30 <span style="color: #0000ff;">NBA &#8212;</span> Brooklyn Nets Vs Houston Rockets Yes Network <a href="http://hdstreams.club/hd/ch13.php">CH13</a> EN<br />06:30 <span style="color: #0000ff;">NBA &#8212;</span> Cleveland Cavaliers Vs Minnesota Timberwolves FOX SPORTS OHIO <a href="http://hdstreams.club/hd/ch14.php">CH14</a> EN<br />07:00 <span style="color: #0000ff;">NBA &#8212;</span> Orlando Magic Vs Milwaukee Bucks FOX SPORTS WISCONSIN <a href="http://hdstreams.club/hd/ch15.php">CH15</a> EN<br />07:00 <span style="color: #0000ff;">NBA &#8212;</span> Detroit Pistons Vs San Antonio Spurs FOX SPORTS DETROIT <a href="http://hdstreams.club/hd/ch16.php">CH16</a> EN<br />07:00 <span style="color: #0000ff;">NBA &#8212;</span> Dallas Mavericks Vs Golden State Warriors NBC SPORTS BAY AREA <a href="http://hdstreams.club/hd/ch17.php">CH17</a> EN<br />07:30 <span style="color: #0000ff;">NBA &#8212;</span> Phoenix Suns Vs Sacramento Kings NBC SPORTS CALIFORNIA <a href="http://hdstreams.club/hd/ch18.php">CH18</a> EN<br />07:30 <span style="color: #0000ff;">Boxing &#8212;</span> Gervonta Davis Vs Yuriorkis Gamboa ShowTime <a href="http://hdstreams.club/hd/ch2.php">CH2</a> EN<br />08:30 <span style="color: #0000ff;">UFC &#8212;</span> Fedor Vs Rampage Paramount Network <a href="http://hdstreams.club/hd/ch4.php">CH4</a> EN<br />08:30 <span style="color: #0000ff;">NBA &#8212;</span> Los Angeles Lakers Vs Portland Trail Blazers NBA TV CANADA <a href="http://hdstreams.club/hd/ch10.php">CH10</a> EN<br />09:00 <span style="color: #0000ff;">NBA &#8212;</span> Utah Jazz Vs LA Clippers FOX SPORTS PRIME TICKET <a href="http://hdstreams.club/hd/ch19.php">CH19</a> EN</p> </div> <div class="col-lg-12"> <hr> <div id="comments" class="comments-area"> </div><!-- #comments --> </div> </div> </div> </div> </div> <!--Sidebar Area--> <aside class="col-md-3 col-lg-3"> <aside id="secondary" class="widget-area" role="complementary"> <div id="sidebar-right" class="pk-sidebar"> <div id="search-2" class="pk-widget widget_search bounceInRight animated"><form method="get" id="searchform" action="http://hdstreams.club/"> <div class="input-group"> <input type="text" class="form-control" name="s" id="s" placeholder="type to search" /> <span class="input-group-btn btn-default "> <button type="submit" class="btn"> <i class="fa fa-search"></i> </button> </span> </div> </form></div> <div id="recent-posts-2" class="pk-widget widget_recent_entries bounceInRight animated"> <h6>Recent Posts</h6> <ul> <li> <a href="http://hdstreams.club/schedule/">Schedule</a> </li> </ul> </div><div id="recent-comments-2" class="pk-widget widget_recent_comments bounceInRight animated"><h6>Recent Comments</h6><ul id="recentcomments"></ul></div><div id="archives-2" class="pk-widget widget_archive bounceInRight animated"><h6>Archives</h6> <ul> <li><a href='http://hdstreams.club/2019/11/'>November 2019</a></li> </ul> </div><div id="categories-2" class="pk-widget widget_categories bounceInRight animated"><h6>Categories</h6> <ul> <li class="cat-item cat-item-1"><a href="http://hdstreams.club/category/uncategorized/">Uncategorized</a> </li> </ul> </div><div id="meta-2" class="pk-widget widget_meta bounceInRight animated"><h6>Meta</h6> <ul> <li><a href="http://hdstreams.club/wp-login.php">Log in</a></li> <li><a href="http://hdstreams.club/feed/">Entries feed</a></li> <li><a href="http://hdstreams.club/comments/feed/">Comments feed</a></li> <li><a href="https://wordpress.org/">WordPress.org</a></li> </ul> </div> </div> </aside><!-- #secondary --> </aside> <!--Sidebar Area--> </div> </div> </main> <!--==================== pk-FOOTER AREA ====================--> <footer> <div class="overlay"> <!--Start pk-footer-widget-area--> <!--End pk-footer-widget-area--> <div class="pk-footer-copyright"> <div class="container"> <div class="row"> <div class="col-md-6"> <p>&copy; 2019 HDSTREAMS.CLUB | Theme by <a href="https://pkhosting.com/" rel="designer">PKHosting</a></p> </div> <div class="col-lg-6 col-sm-6 text-right"> <ul class="pk-social"> </ul> </div> </div> </div> </div> </div> </footer> </div> <!--Scroll To Top--> <a href="#" class="ti_scroll bounceInRight animated"><i class="fa fa-angle-double-up"></i></a> <!--/Scroll To Top--> <script type='text/javascript' src='http://hdstreams.club/wp-includes/js/wp-embed.min.js?ver=5.3.2'></script> </body> </html>` for i, match := range re.FindAllString(str, -1) { fmt.Println(match, "found at index", 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 Golang, please visit: https://golang.org/pkg/regexp/