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"
"
g

Test String

Code Generator

Generated Code

# coding=utf8 # the above tag defines encoding for this document and is for Python 2.x compatibility import re regex = (r"(?xs)<tr>[^<]*?<td.*?>(.*?)</.*?\n" r"<td.*?>.*?(?#skip second col)\n" r"<td.*?>(?:<.*?>)+?((?:(?!<).)*)(?:<.*?>)+?</td.*?\n" r"<td.*?>(.*?)</.*?\n" r"id=([0-9]+)") test_str = ("<!DOCTYPE html>\n" "<html lang=\"en\">\n" "<head>\n" " <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n\n" " <link rel=\"apple-touch-icon\" sizes=\"180x180\" href=\"/apple-touch-icon.png\">\n" " <link rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/favicon-32x32.png\">\n" " <link rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/favicon-16x16.png\">\n" " <link rel=\"manifest\" href=\"/manifest.json\">\n" " <link rel=\"mask-icon\" href=\"/safari-pinned-tab.svg\" color=\"#5bbad5\">\n" " <meta name=\"theme-color\" content=\"#ffffff\">\n\n" " <link rel=\"stylesheet\" href=\"/vendor/font-awesome/css/font-awesome.min.css?v=1510914902\">\n" " <link rel=\"stylesheet\" href=\"/vendor/sortable/sortable-theme-bootstrap.css?v=1510914902\">\n" " <link rel=\"stylesheet\" href=\"/css/pfSense-dark.css?v=1510914901\" />\n\n" " <title>p2fw06.infra.memority.local - System: Certificate Manager: CAs</title>\n" " <script type=\"text/javascript\">\n" " //<![CDATA[\n" " var events = events || [];\n" " //]]>\n" " </script>\n" "<script type=\"text/javascript\">if (top != self) {top.location.href = self.location.href;}</script><script type=\"text/javascript\">var csrfMagicToken = \"sid:3ad881b442e7edf5ea207f041692c5e0620f9c2f,1544601914\";var csrfMagicName = \"__csrf_magic\";</script><script src=\"/csrf/csrf-magic.js\" type=\"text/javascript\"></script></head>\n\n" "<body id=\"2\">\n" "<nav id=\"topmenu\" class=\"navbar navbar-static-top navbar-inverse\">\n" " <div class=\"container\">\n" " <div class=\"navbar-header\">\n" " <button type=\"button\" class=\"navbar-toggle collapsed\" data-toggle=\"collapse\" data-target=\"#pf-navbar\">\n" " <span class=\"sr-only\">Toggle navigation</span>\n" " <span class=\"icon-bar\"></span>\n" " <span class=\"icon-bar\"></span>\n" " <span class=\"icon-bar\"></span>\n" " </button>\n" " <a class=\"navbar-brand\" href=\"/\">\n" " <svg id=\"logo\" role=\"img\" aria-labelledby=\"pfsense-logo\" x=\"0px\" y=\"0px\" viewBox=\"0 0 282.8 84.2\">\n" " <title id=\"pfsense-logo-svg\">pfSense Logo</title>\n" " <path class=\"logo-st0\" d=\"M27.8,57.7c2.9,0,5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.8 c0.3-0.6,0.8-1,1.3-1.3C277.4,65.2,278,65.1,278.6,65.1z\"/>\n" "</svg> <span style=\"color:white;font-size:.5em;text-transform:uppercase;letter-spacing:1px;\">Community Edition</span>\n" " </a>\n" " </div>\n" " <div class=\"collapse navbar-collapse\" id=\"pf-navbar\">\n" " <ul class=\"nav navbar-nav\">\n" " <li class=\"dropdown\">\n" " <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\" role=\"button\" aria-expanded=\"false\">\n" " System <span class=\"caret\"></span>\n" " </a>\n" " <ul class=\"dropdown-menu\" role=\"menu\"><li><a href=\"/system_advanced_admin.php\" class=\"navlnk\" >Advanced</a></li>\n" "<li><a href=\"/system_camanager.php\" class=\"navlnk\" >Cert. Manager</a></li>\n" "<li><a href=\"/system.php\" class=\"navlnk\" >General Setup</a></li>\n" "<li><a href=\"/system_hasync.php\" class=\"navlnk\" >High Avail. Sync</a></li>\n" "<li><a href=\"/index.php?logout\" class=\"navlnk\" usepost>Logout (ecristin)</a></li>\n" "<li><a href=\"/pkg_mgr_installed.php\" class=\"navlnk\" >Package Manager</a></li>\n" "<li><a href=\"/system_gateways.php\" class=\"navlnk\" >Routing</a></li>\n" "<li><a href=\"/wizard.php?xml=setup_wizard.xml\" class=\"navlnk\" >Setup Wizard</a></li>\n" "<li><a href=\"/pkg_mgr_install.php?id=firmware\" class=\"navlnk\" >Update</a></li>\n" "<li><a href=\"/system_usermanager.php\" class=\"navlnk\" >User Manager</a></li>\n" "<li><a href=\"/system_user_settings.php\" class=\"navlnk\" >User Settings</a></li>\n" "</ul>\n" " </li>\n\n" " <li class=\"dropdown\">\n" " <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\" role=\"button\" aria-expanded=\"false\">\n" " Interfaces <span class=\"caret\"></span>\n" " </a>\n" " <ul class=\"dropdown-menu\" role=\"menu\"><li><a href=\"/interfaces_assign.php\" class=\"navlnk\" >Assignments</a></li>\n" " <li class=\"divider\"></li><li><a href=\"/interfaces.php?if=wan\" class=\"navlnk\" >WAN</a></li>\n" "<li><a href=\"/interfaces.php?if=lan\" class=\"navlnk\" >ADMIN</a></li>\n" "<li><a href=\"/interfaces.php?if=opt1\" class=\"navlnk\" >TOOL</a></li>\n" "</ul>\n" " </li>\n\n" " <li class=\"dropdown\">\n" " <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\" role=\"button\" aria-expanded=\"false\">\n" " Firewall <span class=\"caret\"></span>\n" " </a>\n" " <ul class=\"dropdown-menu\" role=\"menu\"><li><a href=\"/firewall_aliases.php\" class=\"navlnk\" >Aliases</a></li>\n" "<li><a href=\"/firewall_nat.php\" class=\"navlnk\" >NAT</a></li>\n" "<li><a href=\"/firewall_rules.php\" class=\"navlnk\" >Rules</a></li>\n" "<li><a href=\"/firewall_schedule.php\" class=\"navlnk\" >Schedules</a></li>\n" "<li><a href=\"/firewall_shaper.php\" class=\"navlnk\" >Traffic Shaper</a></li>\n" "<li><a href=\"/firewall_virtual_ip.php\" class=\"navlnk\" >Virtual IPs</a></li>\n" "</ul>\n" " </li>\n\n" " <li class=\"dropdown\">\n" " <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\" role=\"button\" aria-expanded=\"false\">\n" " Services <span class=\"caret\"></span>\n" " </a>\n" " <ul class=\"dropdown-menu\" role=\"menu\"><li><a href=\"/services_captiveportal.php\" class=\"navlnk\" >Captive Portal</a></li>\n" "<li><a href=\"/services_dhcp_relay.php\" class=\"navlnk\" >DHCP Relay</a></li>\n" "<li><a href=\"/services_dhcp.php\" class=\"navlnk\" >DHCP Server</a></li>\n" "<li><a href=\"/services_dhcpv6_relay.php\" class=\"navlnk\" >DHCPv6 Relay</a></li>\n" "<li><a href=\"/services_dhcpv6.php\" class=\"navlnk\" >DHCPv6 Server &amp; RA</a></li>\n" "<li><a href=\"/services_dnsmasq.php\" class=\"navlnk\" >DNS Forwarder</a></li>\n" "<li><a href=\"/services_unbound.php\" class=\"navlnk\" >DNS Resolver</a></li>\n" "<li><a href=\"/services_dyndns.php\" class=\"navlnk\" >Dynamic DNS</a></li>\n" "<li><a href=\"/services_igmpproxy.php\" class=\"navlnk\" >IGMP Proxy</a></li>\n" "<li><a href=\"/load_balancer_pool.php\" class=\"navlnk\" >Load Balancer</a></li>\n" "<li><a href=\"/pkg_edit.php?xml=nrpe.xml&amp;id=0\" class=\"navlnk\" >NRPEv2</a></li>\n" "<li><a href=\"/services_ntpd.php\" class=\"navlnk\" >NTP</a></li>\n" "<li><a href=\"/services_pppoe.php\" class=\"navlnk\" >PPPoE Server</a></li>\n" "<li><a href=\"/services_snmp.php\" class=\"navlnk\" >SNMP</a></li>\n" "<li><a href=\"/pkg_edit.php?xml=miniupnpd.xml\" class=\"navlnk\" >UPnP &amp; NAT-PMP</a></li>\n" "<li><a href=\"/services_wol.php\" class=\"navlnk\" >Wake-on-LAN</a></li>\n" "</ul>\n" " </li>\n\n" " <li class=\"dropdown\">\n" " <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\" role=\"button\" aria-expanded=\"false\">\n" " VPN <span class=\"caret\"></span>\n" " </a>\n" " <ul class=\"dropdown-menu\" role=\"menu\"><li><a href=\"/vpn_ipsec.php\" class=\"navlnk\" >IPsec</a></li>\n" "<li><a href=\"/vpn_l2tp.php\" class=\"navlnk\" >L2TP</a></li>\n" "<li><a href=\"/vpn_openvpn_server.php\" class=\"navlnk\" >OpenVPN</a></li>\n" "</ul>\n" " </li>\n\n" " <li class=\"dropdown\">\n" " <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\" role=\"button\" aria-expanded=\"false\">\n" " Status <span class=\"caret\"></span>\n" " </a>\n" " <ul class=\"dropdown-menu\" role=\"menu\"><li><a href=\"/status_captiveportal.php\" class=\"navlnk\" >Captive Portal</a></li>\n" "<li><a href=\"/status_carp.php\" class=\"navlnk\" >CARP (failover)</a></li>\n" "<li><a href=\"/index.php\" class=\"navlnk\" >Dashboard</a></li>\n" "<li><a href=\"/status_dhcp_leases.php\" class=\"navlnk\" >DHCP Leases</a></li>\n" "<li><a href=\"/status_dhcpv6_leases.php\" class=\"navlnk\" >DHCPv6 Leases</a></li>\n" "<li><a href=\"/status_filter_reload.php?user=true\" class=\"navlnk\" >Filter Reload</a></li>\n" "<li><a href=\"/status_gateways.php\" class=\"navlnk\" >Gateways</a></li>\n" "<li><a href=\"/status_interfaces.php\" class=\"navlnk\" >Interfaces</a></li>\n" "<li><a href=\"/status_ipsec.php\" class=\"navlnk\" >IPsec</a></li>\n" "<li><a href=\"/status_lb_pool.php\" class=\"navlnk\" >Load Balancer</a></li>\n" "<li><a href=\"/status_monitoring.php\" class=\"navlnk\" >Monitoring</a></li>\n" "<li><a href=\"/status_ntpd.php\" class=\"navlnk\" >NTP</a></li>\n" "<li><a href=\"/status_openvpn.php\" class=\"navlnk\" >OpenVPN</a></li>\n" "<li><a href=\"/status_pkglogs.php\" class=\"navlnk\" >Package Logs</a></li>\n" "<li><a href=\"/status_queues.php\" class=\"navlnk\" >Queues</a></li>\n" "<li><a href=\"/status_services.php\" class=\"navlnk\" >Services</a></li>\n" "<li><a href=\"/status_logs.php\" class=\"navlnk\" >System Logs</a></li>\n" "<li><a href=\"/status_graph.php?if=wan\" class=\"navlnk\" >Traffic Graph</a></li>\n" "<li><a href=\"/status_upnp.php\" class=\"navlnk\" >UPnP &amp; NAT-PMP</a></li>\n" "</ul>\n" " </li>\n\n" " <li class=\"dropdown\">\n" " <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\" role=\"button\" aria-expanded=\"false\">\n" " Diagnostics <span class=\"caret\"></span>\n" " </a>\n" " <ul class=\"dropdown-menu\" role=\"menu\"><li><a href=\"/diag_arp.php\" class=\"navlnk\" >ARP Table</a></li>\n" "<li><a href=\"/diag_authentication.php\" class=\"navlnk\" >Authentication</a></li>\n" "<li><a href=\"/diag_backup.php\" class=\"navlnk\" >Backup &amp; Restore</a></li>\n" "<li><a href=\"/diag_command.php\" class=\"navlnk\" >Command Prompt</a></li>\n" "<li><a href=\"/diag_dns.php\" class=\"navlnk\" >DNS Lookup</a></li>\n" "<li><a href=\"/diag_edit.php\" class=\"navlnk\" >Edit File</a></li>\n" "<li><a href=\"/diag_defaults.php\" class=\"navlnk\" >Factory Defaults</a></li>\n" "<li><a href=\"/diag_halt.php\" class=\"navlnk\" >Halt System</a></li>\n" "<li><a href=\"/diag_limiter_info.php\" class=\"navlnk\" >Limiter Info</a></li>\n" "<li><a href=\"/diag_ndp.php\" class=\"navlnk\" >NDP Table</a></li>\n" "<li><a href=\"/diag_packet_capture.php\" class=\"navlnk\" >Packet Capture</a></li>\n" "<li><a href=\"/diag_pf_info.php\" class=\"navlnk\" >pfInfo</a></li>\n" "<li><a href=\"/diag_pftop.php\" class=\"navlnk\" >pfTop</a></li>\n" "<li><a href=\"/diag_ping.php\" class=\"navlnk\" >Ping</a></li>\n" "<li><a href=\"/diag_reboot.php\" class=\"navlnk\" >Reboot</a></li>\n" "<li><a href=\"/diag_routes.php\" class=\"navlnk\" >Routes</a></li>\n" "<li><a href=\"/diag_smart.php\" class=\"navlnk\" >S.M.A.R.T. Status</a></li>\n" "<li><a href=\"/diag_sockets.php\" class=\"navlnk\" >Sockets</a></li>\n" "<li><a href=\"/diag_dump_states.php\" class=\"navlnk\" >States</a></li>\n" "<li><a href=\"/diag_states_summary.php\" class=\"navlnk\" >States Summary</a></li>\n" "<li><a href=\"/diag_system_activity.php\" class=\"navlnk\" >System Activity</a></li>\n" "<li><a href=\"/diag_tables.php\" class=\"navlnk\" >Tables</a></li>\n" "<li><a href=\"/diag_testport.php\" class=\"navlnk\" >Test Port</a></li>\n" "<li><a href=\"/diag_traceroute.php\" class=\"navlnk\" >Traceroute</a></li>\n" "</ul>\n" " </li>\n\n" " <li class=\"dropdown\">\n" " <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\" role=\"button\" aria-expanded=\"false\">\n" " Help <span class=\"caret\"></span>\n" " </a>\n" " <ul class=\"dropdown-menu\" role=\"menu\"><li><a href=\"/help.php?page=system_camanager.php\" target=\"_blank\" class=\"navlnk\" >About this Page</a></li>\n" "<li><a href=\"https://www.pfsense.org/j.php?jumpto=redmine\" target=\"_blank\" class=\"navlnk\" >Bug Database</a></li>\n" "<li><a href=\"https://www.pfsense.org/j.php?jumpto=doc\" target=\"_blank\" class=\"navlnk\" >Documentation</a></li>\n" "<li><a href=\"https://www.pfsense.org/j.php?jumpto=fbsdhandbook\" target=\"_blank\" class=\"navlnk\" >FreeBSD Handbook</a></li>\n" "<li><a href=\"https://www.netgate.com/support\" target=\"_blank\" class=\"navlnk\" >Paid Support</a></li>\n" "<li><a href=\"https://www.pfsense.org/j.php?jumpto=book\" target=\"_blank\" class=\"navlnk\" >pfSense Book</a></li>\n" "<li><a href=\"https://www.pfsense.org/j.php?jumpto=forum\" target=\"_blank\" class=\"navlnk\" >User Forum</a></li>\n" "</ul>\n" " </li>\n\n" " </ul>\n" " <ul class=\"nav navbar-nav navbar-right\">\n" " <li class=\"dropdown\">\n" " <a href=\"/index.php?logout\" usepost>\n" " <i class=\"fa fa-sign-out\" title=\"Logout (ecristin@p2fw06.infra.memority.local)\"></i>\n" " </a>\n" " </li>\n" " </ul>\n" " </div>\n" " </div>\n" "</nav>\n\n" "<div class=\"container static\" >\n" " <header class=\"header\">\n\n" "<ol class=\"breadcrumb\"><li>System</li><li><a href=\"/system_camanager.php\">Certificate Manager</a></li><li><a href=\"/system_camanager.php\">CAs</a></li></ol> <ul class=\"context-links\">\n\n" " \n" " \n" " \n" " \n" " \n" " \n" " <li>\n" " <a href=\"/help.php?page=system_camanager.php\" target=\"_blank\" title=\"Help for items on this page\">\n" " <i class=\"fa fa-question-circle\"></i>\n" " </a>\n" " </li>\n" " </ul>\n" " </header>\n" "<ul class=\"nav nav-pills\"><li role=\"presentation\" class=\"active\"><a href=\"system_camanager.php\" >CAs</a></li><li role=\"presentation\"><a href=\"system_certmanager.php\" >Certificates</a></li><li role=\"presentation\"><a href=\"system_crlmanager.php\" >Certificate Revocation</a></li></ul><div class=\"panel panel-default\">\n" " <div class=\"panel-heading\"><h2 class=\"panel-title\">Certificate Authorities</h2></div>\n" " <div class=\"panel-body\">\n" " <div class=\"table-responsive\">\n" " <table class=\"table table-striped table-hover table-rowdblclickedit\">\n" " <thead>\n" " <tr>\n" " <th>Name</th>\n" " <th>Internal</th>\n" " <th>Issuer</th>\n" " <th>Certificates</th>\n" " <th>Distinguished Name</th>\n" " <th>In Use</th>\n" " <th>Actions</th>\n" " </tr>\n" " </thead>\n" " <tbody>\n" " <tr>\n" " <td>Memority Root CA</td>\n" " <td><i class=\"fa fa-check\"></i></td>\n" " <td><i>self-signed</i></td>\n" " <td>1</td>\n" " <td>\n" " emailAddress=memority-infra@arismore.fr, ST=Ile-de-France, O=Memority, L=Saint-Cloud, CN=memority-ca, C=FR <br />\n" " <small>\n" " Valid From: <b>Thu, 18 Aug 2016 16:48:17 +0200</b><br />Valid Until: <b>Sun, 16 Aug 2026 16:48:17 +0200</b>\n" " </small>\n" " </td>\n" " <td class=\"text-nowrap\">\n" " </td>\n" " <td class=\"text-nowrap\">\n" " <a class=\"fa fa-pencil\" title=\"Edit CA\" href=\"system_camanager.php?act=edit&amp;id=0\"></a>\n" " <a class=\"fa fa-certificate\" title=\"Export CA\" href=\"system_camanager.php?act=exp&amp;id=0\"></a>\n" " <a class=\"fa fa-key\" title=\"Export key\" href=\"system_camanager.php?act=expkey&amp;id=0\"></a>\n" " <a class=\"fa fa-trash\" title=\"Delete CA and its CRLs\" href=\"system_camanager.php?act=del&amp;id=0\" usepost ></a>\n" " </td>\n" " </tr>\n" " <tr>\n" " <td>Memority Tool Users CA</td>\n" " <td><i class=\"fa fa-check\"></i></td>\n" " <td><i>Memority Root CA</i></td>\n" " <td>22</td>\n" " <td>\n" " emailAddress=ops-memority@accenture.com, ST=Ile_de_France, OU=tool_zone, O=Memority, L=Saint-Cloud, CN=memority-tool-users-ca, C=FR <br />\n" " <small>\n" " Valid From: <b>Tue, 06 Mar 2018 11:07:12 +0100</b><br />Valid Until: <b>Fri, 03 Mar 2028 11:07:12 +0100</b>\n" " </small>\n" " </td>\n" " <td class=\"text-nowrap\">\n" " OpenVPN Server<br/>\n" " </td>\n" " <td class=\"text-nowrap\">\n" " <a class=\"fa fa-pencil\" title=\"Edit CA\" href=\"system_camanager.php?act=edit&amp;id=1\"></a>\n" " <a class=\"fa fa-certificate\" title=\"Export CA\" href=\"system_camanager.php?act=exp&amp;id=1\"></a>\n" " <a class=\"fa fa-key\" title=\"Export key\" href=\"system_camanager.php?act=expkey&amp;id=1\"></a>\n" " </td>\n" " </tr>\n" " </tbody>\n" " </table>\n" " </div>\n" " </div>\n" "</div>\n\n" "<nav class=\"action-buttons\">\n" " <a href=\"?act=new\" class=\"btn btn-success btn-sm\">\n" " <i class=\"fa fa-plus icon-embed-btn\"></i>\n" " Add </a>\n" "</nav>\n" " </div>\n" " <footer class=\"footer\">\n" " <div class=\"container\">\n" " <p class=\"text-muted\">\n" " <a id=\"tpl\" style=\"display: none;\" href=\"#\" title=\"Top of page\"><i class=\"fa fa-caret-square-o-up pull-left\"></i></a>\n" " <a target=\"_blank\" href=\"https://www.pfsense.org/?gui=bootstrap\">pfSense</a> is &copy;\n" " 2004 - 2018 by <a href=\"https://pfsense.org/license\" class=\"tblnk\">Rubicon Communications, LLC (Netgate)</a>. All Rights Reserved.\n" " [<a href=\"/license.php\" class=\"tblnk\">view license</a>]\n" " <a id=\"tpr\" style=\"display: none;\" href=\"#\" title=\"Top of page\"><i class=\"fa fa-caret-square-o-up pull-right\"></i></a>\n" " </p>\n" " </div>\n" " </footer>\n\n" " <!-- This use of filemtime() is intended to fool the browser into reloading the file (not using the cached version) if the file is changed -->\n\n" " <script src=\"/vendor/jquery/jquery-1.12.0.min.js?v=1510914902\"></script>\n" " <script src=\"/vendor/jquery/jquery-ui-1.11.4.min.js?v=1510914902\"></script>\n" " <script src=\"/vendor/bootstrap/js/bootstrap.min.js?v=1510914902\"></script>\n" " <script src=\"/js/pfSense.js?v=1513000593\"></script>\n" " <script src=\"/js/pfSenseHelpers.js?v=1510914901\"></script>\n" " <script src=\"/js/polyfills.js?v=1510914901\"></script>\n" " <script src=\"/vendor/sortable/sortable.js?v=1510914902\"></script>\n\n" " <script type=\"text/javascript\">\n" " //<![CDATA[\n" " // Un-hide the \"Top of page\" icons if the page is larger than the window\n" " if ($(document).height() > $(window).height()) {\n" " $('[id^=tp]').show();\n" " }\n" " //]]>\n" " </script>\n" "<script type=\"text/javascript\">CsrfMagic.end();</script></body>\n" "</html>\n") matches = re.finditer(regex, test_str) for matchNum, match in enumerate(matches, start=1): print ("Match {matchNum} was found at {start}-{end}: {match}".format(matchNum = matchNum, start = match.start(), end = match.end(), match = match.group())) for groupNum in range(0, len(match.groups())): groupNum = groupNum + 1 print ("Group {groupNum} found at {start}-{end}: {group}".format(groupNum = groupNum, start = match.start(groupNum), end = match.end(groupNum), group = match.group(groupNum))) # Note: for Python 2.7 compatibility, use ur"" to prefix the regex and u"" to prefix the test string and substitution.

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 Python, please visit: https://docs.python.org/3/library/re.html