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

/
/
g

Test String

Code Generator

Generated Code

#include <StringConstants.au3> ; to declare the Constants of StringRegExp #include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate Local $sRegex = "(((1[0-9]{2})|(2[0-5]{2})|[0-9]{1,2})\.){3}(((1[0-9]{2})|(2[0-5]{2})|[0-9]{1,2})):(\d{5})" Local $sString = "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">" & @CRLF & _ "<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">" & @CRLF & _ " <head>" & @CRLF & _ " <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />" & @CRLF & _ " <meta name="title" content="eBot :: Your ingame bot manager for CS:GO" />" & @CRLF & _ " <title>eBot :: Your ingame bot manager for CS:GO</title>" & @CRLF & _ " <link rel="shortcut icon" type="image/png" href="/favicon.png" />" & @CRLF & _ " <link rel="stylesheet" type="text/css" media="screen" href="/css/bootstrap.min.css" />" & @CRLF & _ "<link rel="stylesheet" type="text/css" media="screen" href="/css/bootstrap-responsive.min.css" />" & @CRLF & _ "<link rel="stylesheet" type="text/css" media="screen" href="/css/tipsy.css" />" & @CRLF & _ "<link rel="stylesheet" type="text/css" media="screen" href="/css/datatable.bootstrap.css" />" & @CRLF & _ "<link rel="stylesheet" type="text/css" media="screen" href="/css/flags.css" />" & @CRLF & _ "<link rel="stylesheet" type="text/css" media="screen" href="/css/hubinfo.min.css" />" & @CRLF & _ " <script type="text/javascript" src="/js/jquery-1.8.2.min.js"></script>" & @CRLF & _ "<script type="text/javascript" src="/js/bootstrap.min.js"></script>" & @CRLF & _ "<script type="text/javascript" src="/js/jquery.validate.min.js"></script>" & @CRLF & _ "<script type="text/javascript" src="/js/jquery.tipsy.js"></script>" & @CRLF & _ "<script type="text/javascript" src="/js/jquery.tablesorter.min.js"></script>" & @CRLF & _ "<script type="text/javascript" src="/js/jquery.datatable.min.js"></script>" & @CRLF & _ "<script type="text/javascript" src="/js/datatable.bootstrap.js"></script>" & @CRLF & _ "<script type="text/javascript" src="/js/heatmap.js"></script>" & @CRLF & _ "<script type="text/javascript" src="/js/raphael-min.js"></script>" & @CRLF & _ "<script type="text/javascript" src="/js/jquery.iphone-switch.js"></script>" & @CRLF & _ "<script type="text/javascript" src="/js/hubinfo.min.js"></script>" & @CRLF & _ "<script type="text/javascript" src="/js/pnotify.custom.min.js"></script>" & @CRLF & _ "<script type="text/javascript" src="/js/aes.js"></script>" & @CRLF & _ " <style type="text/css">" & @CRLF & _ " body {" & @CRLF & _ " padding-top: 60px;" & @CRLF & _ " padding-bottom: 40px;" & @CRLF & _ " }" & @CRLF & _ " .sidebar-nav {" & @CRLF & _ " padding: 9px 0;" & @CRLF & _ " }" & @CRLF & _ " </style>" & @CRLF & _ " <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->" & @CRLF & _ " <!--[if lt IE 9]>" & @CRLF & _ " <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>" & @CRLF & _ " <![endif]-->" & @CRLF & _ " </head>" & @CRLF & _ " <body>" & @CRLF & _ " <script>" & @CRLF & _ " function submitForm(id) {" & @CRLF & _ " $("#" + id).submit();" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " var socketIoAddress = "176.31.211.228:12370";" & @CRLF & _ " var socket = null;" & @CRLF & _ " var socketIoLoaded = false;" & @CRLF & _ " var loadingSocketIo = false;" & @CRLF & _ " var callbacks = new Array();" & @CRLF & _ " function initSocketIo(callback) {" & @CRLF & _ " callbacks.push(callback);" & @CRLF & _ " if (loadingSocketIo) {" & @CRLF & _ " return;" & @CRLF & _ " }" & @CRLF & _ " " & @CRLF & _ " if (socketIoLoaded) {" & @CRLF & _ " if (typeof callback == "function") {" & @CRLF & _ " callback(socket);" & @CRLF & _ " }" & @CRLF & _ " return;" & @CRLF & _ " }" & @CRLF & _ " " & @CRLF & _ " loadingSocketIo = true;" & @CRLF & _ " $.getScript("http://"+socketIoAddress+"/socket.io/socket.io.js", function(){" & @CRLF & _ " socket = io.connect("http://"+socketIoAddress);" & @CRLF & _ " socket.on('connect', function(){ " & @CRLF & _ " socketIoLoaded = true;" & @CRLF & _ " loadingSocketIo = false;" & @CRLF & _ " if (typeof callback == "function") {" & @CRLF & _ " callback(socket);" & @CRLF & _ " }" & @CRLF & _ " for (var c in callbacks) {" & @CRLF & _ " callbacks[c](socket);" & @CRLF & _ " }" & @CRLF & _ " //callbacks = new Array();" & @CRLF & _ " });" & @CRLF & _ " });" & @CRLF & _ " }" & @CRLF & _ " </script>" & @CRLF & _ " <div class="navbar navbar-inverse navbar-fixed-top">" & @CRLF & _ " <div class="navbar-inner">" & @CRLF & _ " <div class="container-fluid">" & @CRLF & _ " <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">" & @CRLF & _ " <span class="icon-bar"></span>" & @CRLF & _ " <span class="icon-bar"></span>" & @CRLF & _ " <span class="icon-bar"></span>" & @CRLF & _ " </a>" & @CRLF & _ " <a class="brand" href="/">eBot-CSGO</a>" & @CRLF & _ " <div class="nav-collapse collapse">" & @CRLF & _ " <div style="line-height: 35px; float: right; margin-right: 10px;">" & @CRLF & _ " <form style="display:inline; margin-left: 5px; cursor: pointer" action="/switch/lang/fr" method="POST" id="langFr"><input type="hidden" name="referer" value="/servers" /><img onclick="javascript:submitForm('langFr')" src="/images/fr.png" /></form>" & @CRLF & _ " <form style="display:inline; margin-left: 5px; cursor: pointer" action="/switch/lang/en" method="POST" id="langEn"><input type="hidden" name="referer" value="/servers" /><img onclick="javascript:submitForm('langEn')" src="/images/en.png" /></form>" & @CRLF & _ " <form style="display:inline; margin-left: 5px; cursor: pointer" action="/switch/lang/de" method="POST" id="langDe"><input type="hidden" name="referer" value="/servers" /><img onclick="javascript:submitForm('langDe')" src="/images/de.png" /></form>" & @CRLF & _ " <form style="display:inline; margin-left: 5px; cursor: pointer" action="/switch/lang/cn" method="POST" id="langCn"><input type="hidden" name="referer" value="/servers" /><img onclick="javascript:submitForm('langCn')" src="/images/cn.gif" /></form>" & @CRLF & _ " </div>" & @CRLF & _ " " & @CRLF & _ " <p class="navbar-text pull-right">" & @CRLF & _ " Logged in as <a href="#" class="navbar-link">tictax</a>" & @CRLF & _ " </p>" & @CRLF & _ " <ul class="nav">" & @CRLF & _ " <li class="active"><a href="/">Home</a></li>" & @CRLF & _ " <li><a href="http://www.esport-tools.net/ebot">Help</a></li>" & @CRLF & _ " <li><a href="http://www.esport-tools.net/about">About</a></li>" & @CRLF & _ " </ul>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ "" & @CRLF & _ " <div class="container-fluid">" & @CRLF & _ " <div class="row-fluid">" & @CRLF & _ " <div class="span2">" & @CRLF & _ " <div class="well sidebar-nav">" & @CRLF & _ " <script>" & @CRLF & _ " function goToMatch() {" & @CRLF & _ " var id = $("#match_id_go").val();" & @CRLF & _ " if (id > 0)" & @CRLF & _ " document.location.href = "/matchs/view/"+id;" & @CRLF & _ " };" & @CRLF & _ " </script>" & @CRLF & _ " <ul class="nav nav-list">" & @CRLF & _ " <li class="nav-header">Main Menu</li>" & @CRLF & _ " <li ><a href="/">Home</a></li>" & @CRLF & _ " <li ><a href="/stats">Statistics</a></li>" & @CRLF & _ " <li ><a href="/credits">Credits</a></li>" & @CRLF & _ " <!--<li ><a href="/main/ingame">Ingame Help</a></li>-->" & @CRLF & _ " <li class="nav-header">Match Menu</li>" & @CRLF & _ " <li ><a href="/matchs/current/1">Matches in Progress <span class="badge badge-info">39</span></a></li>" & @CRLF & _ " <li ><a href="/matchs/archived/1">Archived Matches</a></li>" & @CRLF & _ " <li ><a href="/seasons">Seasons Overview</a></li>" & @CRLF & _ " <li class="nav-header">Match Management</li>" & @CRLF & _ " <li ><a href="/matchs/create">Create a match</a></li>" & @CRLF & _ " <li ><a href="/matchs/user">My matchs <span class="badge badge-info">0</span></a></li>" & @CRLF & _ " <li class="nav-header">Team Management</li>" & @CRLF & _ " <li><a href="/teams/create">Create Team</a></li>" & @CRLF & _ " <li><a href="/teams">Team Management</a></li>" & @CRLF & _ " <li class="nav-header">Server Management</li>" & @CRLF & _ " <li ><a href="/servers/create">Add Gameserver</a></li>" & @CRLF & _ " <li><a href="/servers">Server Management</a></li>" & @CRLF & _ " <li class="nav-header">Statistics</li>" & @CRLF & _ " <li ><a href="/stats/global">Global Statistics</a></li>" & @CRLF & _ " <li ><a href="/stats/maps">Statistics by Map</a></li>" & @CRLF & _ " <li ><a href="/stats/weapons">Statistics by Weapon</a></li>" & @CRLF & _ " </ul>" & @CRLF & _ " </div>" & @CRLF & _ "</div>" & @CRLF & _ " <div class="span10">" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " <h3>Server Management (1/2)</h3>" & @CRLF & _ "<hr/>" & @CRLF & _ "<table class="table table-striped">" & @CRLF & _ " <thead>" & @CRLF & _ " <tr>" & @CRLF & _ " <th>#ID</th>" & @CRLF & _ " <th>IP Adress</th>" & @CRLF & _ " <th>Name</th>" & @CRLF & _ " <th>used?</th>" & @CRLF & _ " <th>Action</th>" & @CRLF & _ " </tr>" & @CRLF & _ " </thead>" & @CRLF & _ " <tbody>" & @CRLF & _ " <tr>" & @CRLF & _ " <td width="30">3243</td>" & @CRLF & _ " <td width="200">85.14.230.26:27015</td>" & @CRLF & _ " <td>Xylonm Gameserver</td>" & @CRLF & _ " <td width="100">" & @CRLF & _ " <img src="/images/icons/flag_red.png" /> not used </td>" & @CRLF & _ " <td width="100">" & @CRLF & _ " <a href="/servers/delete/3243"><button class="btn btn-danger">Delete</button></a>" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " </tbody>" & @CRLF & _ "" & @CRLF & _ "</table> </div>" & @CRLF & _ " </div>" & @CRLF & _ "" & @CRLF & _ " <!-- Please, don't remove the brand -->" & @CRLF & _ " <footer class="footer">" & @CRLF & _ " <p>&copy; <a target="_blank" href="http://www.esport-tools.net/ebot">eSport-tools</a> 2012-2013 - 3.1.0 Public - By deStrO &amp; Basert - Follow me on <a target="_blank" href="https://twitter.com/deStrO_BE">Twitter</a> - Propulsed by <a target="_blank" href="http://twitter.github.com/bootstrap">Bootstrap</a> & <a target="_blank" href="http://www.symfony-project.com">Symfony</a> - Follow eBot on <a target="_blank" href="https://github.com/deStrO/eBot-CSGO">GitHub</a></p>" & @CRLF & _ " </footer>" & @CRLF & _ "" & @CRLF & _ "<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">" & @CRLF & _ "<input type="hidden" name="cmd" value="_donations">" & @CRLF & _ "<input type="hidden" name="business" value="destro@esport-tools.net">" & @CRLF & _ "<input type="hidden" name="lc" value="BE">" & @CRLF & _ "<input type="hidden" name="item_name" value="eSport-tools.net">" & @CRLF & _ "<input type="hidden" name="no_note" value="0">" & @CRLF & _ "<input type="hidden" name="currency_code" value="EUR">" & @CRLF & _ "<input type="hidden" name="bn" value="PP-DonationsBF:btn_donateCC_LG.gif:NonHostedGuest">" & @CRLF & _ "<input type="image" src="https://www.paypalobjects.com/en_US/BE/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">" & @CRLF & _ "<img alt="" border="0" src="https://www.paypalobjects.com/fr_XC/i/scr/pixel.gif" width="1" height="1">" & @CRLF & _ "</form>" & @CRLF & _ " </div>" & @CRLF & _ " <script type="text/javascript">" & @CRLF & _ "" & @CRLF & _ " var _gaq = _gaq || [];" & @CRLF & _ " _gaq.push(['_setAccount', 'UA-22008669-4']);" & @CRLF & _ " _gaq.push(['_trackPageview']);" & @CRLF & _ "" & @CRLF & _ " (function() {" & @CRLF & _ " var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;" & @CRLF & _ " ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';" & @CRLF & _ " var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);" & @CRLF & _ " })();" & @CRLF & _ "" & @CRLF & _ "</script>" & @CRLF & _ " </body>" & @CRLF & _ "</html>" & @CRLF & _ "" Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYGLOBALFULLMATCH) Local $aFullArray[0] For $i = 0 To UBound($aArray) -1 _ArrayConcatenate($aFullArray, $aArray[$i]) Next $aArray = $aFullArray ; Present the entire match result _ArrayDisplay($aArray, "Result")

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 AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm