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

import java.util.regex.Matcher; import java.util.regex.Pattern; public class Example { public static void main(String[] args) { final String regex = "&#8212;</span> (.+?) <a.+?href=\\\"(.+?)\\\">CH(.+?)<.+?/>(.+?) <"; final String string = "\n" + "<!DOCTYPE html>\n" + "<html lang=\"en-US\">\n" + "<head>\n" + "<meta charset=\"UTF-8\">\n" + "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n" + "<title>HDSTREAMS.CLUB &#8211; Watch Soccer, NBA, NFL, Racing and Fighting Games Live</title>\n" + "<link rel='dns-prefetch' href='//fonts.googleapis.com' />\n" + "<link rel='dns-prefetch' href='//s.w.org' />\n" + "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"HDSTREAMS.CLUB &raquo; Feed\" href=\"http://hdstreams.club/feed/\" />\n" + "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"HDSTREAMS.CLUB &raquo; Comments Feed\" href=\"http://hdstreams.club/comments/feed/\" />\n" + " <script type=\"text/javascript\">\n" + " 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\"}};\n" + " !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);\n" + " </script>\n" + " <style type=\"text/css\">\n" + "img.wp-smiley,\n" + "img.emoji {\n" + " display: inline !important;\n" + " border: none !important;\n" + " box-shadow: none !important;\n" + " height: 1em !important;\n" + " width: 1em !important;\n" + " margin: 0 .07em !important;\n" + " vertical-align: -0.1em !important;\n" + " background: none !important;\n" + " padding: 0 !important;\n" + "}\n" + "</style>\n" + " <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' />\n" + "<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' />\n" + "<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' />\n" + "<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' />\n" + "<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' />\n" + "<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' />\n" + "<script type='text/javascript' src='http://hdstreams.club/wp-includes/js/jquery/jquery.js?ver=1.12.4-wp'></script>\n" + "<script type='text/javascript' src='http://hdstreams.club/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.4.1'></script>\n" + "<script type='text/javascript' src='http://hdstreams.club/wp-content/themes/pkhosting/js/bootstrap.js?ver=5.3.2'></script>\n" + "<script type='text/javascript' src='http://hdstreams.club/wp-content/themes/pkhosting/js/jquery.smartmenus.min.js?ver=5.3.2'></script>\n" + "<link rel='https://api.w.org/' href='http://hdstreams.club/wp-json/' />\n" + "<link rel=\"EditURI\" type=\"application/rsd+xml\" title=\"RSD\" href=\"http://hdstreams.club/xmlrpc.php?rsd\" />\n" + "<link rel=\"wlwmanifest\" type=\"application/wlwmanifest+xml\" href=\"http://hdstreams.club/wp-includes/wlwmanifest.xml\" /> \n" + "<meta name=\"generator\" content=\"WordPress 5.3.2\" />\n" + "<link rel=\"canonical\" href=\"http://hdstreams.club/\" />\n" + "<link rel='shortlink' href='http://hdstreams.club/' />\n" + "<link rel=\"alternate\" type=\"application/json+oembed\" href=\"http://hdstreams.club/wp-json/oembed/1.0/embed?url=http%3A%2F%2Fhdstreams.club%2F\" />\n" + "<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\" />\n\n" + " <style type=\"text/css\">\n" + " </style>\n\n" + "<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>\n\n" + "<body class=\"home page-template-default page page-id-5\">\n" + "<div class=\"wrapper\">\n" + " <header>\n" + " <div class=\"clearfix\"></div>\n" + " <div class=\"pk-main-nav\">\n" + " <div class=\"container\">\n" + " <div class=\"row\">\n" + " <div class=\"col-xs-12 col-sm-3\">\n" + " <div class=\"navbar-header\">\n" + " <!-- Logo -->\n" + " \n" + " <a class=\"navbar-brand\" href=\"http://hdstreams.club/\"><span class=\"site-title\">HDSTREAMS.CLUB</span>\n" + " <br>\n" + " <span class=\"site-description\">Watch Soccer, NBA, NFL, Racing and Fighting Games Live</span> \n" + " </a> \n" + " \n" + " <!-- Logo -->\n" + " </div>\n" + " </div>\n" + " <div class=\"col-xs-12 col-sm-9 main-menu\" >\n" + " <nav class=\"navbar navbar-default navbar-static-top navbar-wp\">\n" + " <!-- navbar-toggle -->\n" + " <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>\n" + " <!-- /navbar-toggle --> \n" + " <!-- Navigation -->\n" + " \n" + " <div class=\"collapse navbar-collapse\" id=\"navbar-wp\">\n" + " \n" + " </div>\n" + " <!-- /Navigation -->\n" + " </nav>\n" + " </div>\n" + " </div>\n" + " </div>\n" + " </div>\n" + " </header>\n" + " <!-- #masthead --> \n\n" + "<main id=\"content\">\n" + " <div class=\"container\">\n" + " <div class=\"row\">\n" + " <div class=\"col-lg-9 col-md-9\">\n" + " <div class=\"single-content-container\">\n" + " <div class=\"row\">\n" + " <div class=\"col-lg-12\">\n" + " <div class=\"page-content\">\n" + " <h1>Today&#8217;s Schedule</h1> \n" + " \n" + "<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>\n\n\n\n" + "<h2><span style=\"text-decoration: underline; color: #993300;\">Schedule Time is IST 05:30</span></h2>\n\n\n" + "<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>\n\n\n" + "<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>\n\n\n\n" + "<h2><span style=\"text-decoration: underline; color: #993300;\">Schedule Time is IST 05:30</span></h2>\n\n\n" + "<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>\n" + " <div class=\"col-lg-12\">\n" + "<hr>\n" + "<div id=\"comments\" class=\"comments-area\">\n" + " \n" + "</div><!-- #comments -->\n" + "</div> </div>\n" + " </div> \n" + " </div> \n" + " </div>\n" + " <!--Sidebar Area-->\n" + " <aside class=\"col-md-3 col-lg-3\">\n" + " \n" + "<aside id=\"secondary\" class=\"widget-area\" role=\"complementary\">\n" + " <div id=\"sidebar-right\" class=\"pk-sidebar\">\n" + " <div id=\"search-2\" class=\"pk-widget widget_search bounceInRight animated\"><form method=\"get\" id=\"searchform\" action=\"http://hdstreams.club/\">\n" + " <div class=\"input-group\">\n" + " <input type=\"text\" class=\"form-control\" name=\"s\" id=\"s\" placeholder=\"type to search\" />\n" + " <span class=\"input-group-btn btn-default \">\n" + " <button type=\"submit\" class=\"btn\"> <i class=\"fa fa-search\"></i> </button>\n" + " </span> </div>\n" + "</form></div> <div id=\"recent-posts-2\" class=\"pk-widget widget_recent_entries bounceInRight animated\"> <h6>Recent Posts</h6> <ul>\n" + " <li>\n" + " <a href=\"http://hdstreams.club/schedule/\">Schedule</a>\n" + " </li>\n" + " </ul>\n" + " </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>\n" + " <li><a href='http://hdstreams.club/2019/11/'>November 2019</a></li>\n" + " </ul>\n" + " </div><div id=\"categories-2\" class=\"pk-widget widget_categories bounceInRight animated\"><h6>Categories</h6> <ul>\n" + " <li class=\"cat-item cat-item-1\"><a href=\"http://hdstreams.club/category/uncategorized/\">Uncategorized</a>\n" + "</li>\n" + " </ul>\n" + " </div><div id=\"meta-2\" class=\"pk-widget widget_meta bounceInRight animated\"><h6>Meta</h6> <ul>\n" + " <li><a href=\"http://hdstreams.club/wp-login.php\">Log in</a></li>\n" + " <li><a href=\"http://hdstreams.club/feed/\">Entries feed</a></li>\n" + " <li><a href=\"http://hdstreams.club/comments/feed/\">Comments feed</a></li>\n" + " <li><a href=\"https://wordpress.org/\">WordPress.org</a></li> </ul>\n" + " </div> </div>\n" + "</aside><!-- #secondary --> </aside>\n" + " <!--Sidebar Area-->\n" + " </div>\n" + " </div>\n" + "</main>\n" + "<!--==================== pk-FOOTER AREA ====================-->\n" + "<footer> \n" + " <div class=\"overlay\"> \n" + " <!--Start pk-footer-widget-area-->\n" + " <!--End pk-footer-widget-area-->\n" + " <div class=\"pk-footer-copyright\">\n" + " <div class=\"container\">\n" + " <div class=\"row\">\n" + " <div class=\"col-md-6\">\n" + " <p>&copy; 2019 HDSTREAMS.CLUB | Theme by <a href=\"https://pkhosting.com/\" rel=\"designer\">PKHosting</a></p>\n" + " </div>\n" + " <div class=\"col-lg-6 col-sm-6 text-right\">\n" + " <ul class=\"pk-social\">\n" + " </ul>\n" + " </div>\n" + " </div>\n" + " </div>\n" + " </div>\n" + " </div>\n" + "</footer>\n" + "</div>\n" + "<!--Scroll To Top--> \n" + "<a href=\"#\" class=\"ti_scroll bounceInRight animated\"><i class=\"fa fa-angle-double-up\"></i></a> \n" + "<!--/Scroll To Top-->\n" + "<script type='text/javascript' src='http://hdstreams.club/wp-includes/js/wp-embed.min.js?ver=5.3.2'></script>\n" + "</body>\n" + "</html>"; final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE); 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