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 = "<tr[^>]*>[^<]*<td[^>]*>(?<No>[^<]*)<[^>]*>[^>]*>(?<ID_dist>[^<]*)<\/td>[^>]*>(?<Jmeno>[^<]*)<\/td>[^>]*>(?<Tel_Home>[^<]*)<\/td>[^>]*>(?<Tel_Buss>[^<]*)<\/td>[^>]*>(?<Tel_mob>[^<]*)<\/td>[^>]*>(?<Country>[^<]*)<\/td>[^>]*><a[^>]*>(?<Email>[^<]*)[^<]*<\/a>[^<]*<\/td>[^>]*>(?<Levels>[^<]*)<\/td>[^>]*>(?<Pozice>[^<]*)<\/td>[^>]*>(?<Sponzor_ID>[^<]*)<\/td>" Local $sString = "" & @CRLF & _ " <!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">" & @CRLF & _ "<head>" & @CRLF & _ "<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />" & @CRLF & _ "<title>PBC - Distributors to be Renewed List</title>" & @CRLF & _ "<meta name="description" content="Lifestyles PBC is an on-line tool to help our Distributors manage their business and achieve their goals." />" & @CRLF & _ "<meta name="keywords" content="Lifestyles, Lifestyles International, Personal Business Center, PBC"/>" & @CRLF & _ "<link href="css/en.css" rel="stylesheet" type="text/css" />" & @CRLF & _ "</head>" & @CRLF & _ "<body bgcolor="#EAF4D1" leftmargin="0" topmargin="3" marginwidth="0" marginheight="0">" & @CRLF & _ "<table border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#999999">" & @CRLF & _ " <tr> <td height="33" colspan="11" align="center" bgcolor="#FFFFFF"><h2 style="margin: 10px">Distributors to be Renewed List</h2>" & @CRLF & _ " <p style="margin: 10px">Month: Nov. 2017</p></td>" & @CRLF & _ " </tr>" & @CRLF & _ " <tr>" & @CRLF & _ " <td height="27" align="center" bgcolor="#CCCCCC"><strong>No.</strong></td>" & @CRLF & _ " <td height="27" align="center" bgcolor="#CCCCCC"><strong>ID</strong></td>" & @CRLF & _ " <td height="27" align="center" bgcolor="#CCCCCC"><strong>Name</strong></td>" & @CRLF & _ " <td align="center" bgcolor="#CCCCCC"><strong>Home Phone</strong></td>" & @CRLF & _ " <td align="center" bgcolor="#CCCCCC"><strong>Business Phone</strong></td>" & @CRLF & _ " <td align="center" bgcolor="#CCCCCC"><strong>Cell Phone</strong></td>" & @CRLF & _ " <td align="center" bgcolor="#CCCCCC"><strong>Country</strong></td>" & @CRLF & _ " <td align="center" bgcolor="#CCCCCC"><strong>Email</strong></td>" & @CRLF & _ " <td align="center" bgcolor="#CCCCCC"><strong>Levels</strong></td>" & @CRLF & _ " <td align="center" bgcolor="#CCCCCC"><strong>Rank</strong></td>" & @CRLF & _ " <td align="center" bgcolor="#CCCCCC"><strong>Sponsor</strong></td>" & @CRLF & _ " </tr>" & @CRLF & _ " <tr>" & @CRLF & _ " <td height="27" align="center" bgcolor="#FFFFFF">1</td>" & @CRLF & _ " <td height="27" align="center" bgcolor="#FFFFFF">98000204732</td>" & @CRLF & _ " <td height="27" align="center" bgcolor="#FFFFFF">Pavel Kaleta</td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF">420 773512280</td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF"></td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF"></td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF">Czech Republic</td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF"><a href="mailto:"></a></td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF">19</td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF">Distributor</td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF">80011630542</td>" & @CRLF & _ " </tr>" & @CRLF & _ " <tr>" & @CRLF & _ " <td height="27" align="center" bgcolor="#FFFFFF">2</td>" & @CRLF & _ " <td height="27" align="center" bgcolor="#FFFFFF">98000229140</td>" & @CRLF & _ " <td height="27" align="center" bgcolor="#FFFFFF">Ivana Bilkova</td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF">420 605934970</td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF"></td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF"></td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF">Czech Republic</td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF"><a href="mailto:ifcabilkova@seznam.cz">ifcabilkova@seznam.cz</a></td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF">20</td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF">Distributor</td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF">98000142059</td>" & @CRLF & _ " </tr>" & @CRLF & _ " <tr>" & @CRLF & _ " <td height="27" align="center" bgcolor="#FFFFFF">3</td>" & @CRLF & _ " <td height="27" align="center" bgcolor="#FFFFFF">98000229289</td>" & @CRLF & _ " <td height="27" align="center" bgcolor="#FFFFFF">Martina Vitkovska</td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF">420 606629784</td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF"></td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF"></td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF">Czech Republic</td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF"><a href="mailto:martinavitkovska@seznam.cz">martinavitkovska@seznam.cz</a></td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF">18</td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF">Distributor</td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF">13980242</td>" & @CRLF & _ " </tr>" & @CRLF & _ " <tr>" & @CRLF & _ " <td height="27" align="center" bgcolor="#FFFFFF">4</td>" & @CRLF & _ " <td height="27" align="center" bgcolor="#FFFFFF">98000253035</td>" & @CRLF & _ " <td height="27" align="center" bgcolor="#FFFFFF">Lenka Lovetinska</td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF">420 60598685</td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF">420 567223836</td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF"></td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF">Czech Republic</td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF"><a href="mailto:lovetinskal@seznam.cz">lovetinskal@seznam.cz</a></td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF">20</td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF">Distributor</td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF">98000142059</td>" & @CRLF & _ " </tr>" & @CRLF & _ " <tr>" & @CRLF & _ " <td height="27" align="center" bgcolor="#FFFFFF">5</td>" & @CRLF & _ " <td height="27" align="center" bgcolor="#FFFFFF">98000253463</td>" & @CRLF & _ " <td height="27" align="center" bgcolor="#FFFFFF">Filip Korda</td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF">421 902483141</td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF">421 948186144</td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF"></td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF">Slovak Republic</td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF"><a href="mailto:korda@sanusvita.sk">korda@sanusvita.sk</a></td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF">20</td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF">Distributor</td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF">80011633242</td>" & @CRLF & _ " </tr>" & @CRLF & _ " <tr>" & @CRLF & _ " <td height="27" align="center" bgcolor="#FFFFFF">6</td>" & @CRLF & _ " <td height="27" align="center" bgcolor="#FFFFFF">CZ-03-04277</td>" & @CRLF & _ " <td height="27" align="center" bgcolor="#FFFFFF">Olga Kostomarova</td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF">420 603160599</td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF"></td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF"></td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF">Czech Republic</td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF"><a href="mailto:"></a></td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF">19</td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF">Distributor</td>" & @CRLF & _ " <td align="center" bgcolor="#FFFFFF">80011630542</td>" & @CRLF & _ " </tr>" & @CRLF & _ " </table>" & @CRLF & _ "</body>" & @CRLF & _ "</html>" & @CRLF & _ "<script>window.focus()</script>" & @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