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

#include <StringConstants.au3> ; to declare the Constants of StringRegExp #include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate Local $sRegex = "(?m)nowrap=\"nowrap\" align=\"center.+?>(.+?)<\/td.+\n.+?align=\"right\"><a href=\"/.+?\/\">(.+?)<\/a>.+\n.+\n.+?href=\"\/teams\/.+?\">(.+?)<\/a>" Local $sString = " <tr>" & @CRLF & _ " <td class="hell" nowrap="nowrap" align="center">01:00</td>" & @CRLF & _ " <td class="hell" align="right"><a href="/teams/bayern-muenchen/">Bayern München</a></td>" & @CRLF & _ " <td class="hell" align="center"> - </td>" & @CRLF & _ " <td class="hell"><a href="/teams/real-madrid/">Real Madrid</a></td>" & @CRLF & _ " <td class="hell" align="center" nowrap>" & @CRLF & _ " <a href="/report/freundschaft-vereine-2019-kalenderwoche-bayern-muenchen-real-madrid/" title="Match details Bayern München - Real Madrid">3:1 (1:0) </a>" & @CRLF & _ " </td>" & @CRLF & _ " <td class="hell" align="center">" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " " & @CRLF & _ " <tr>" & @CRLF & _ " <td class="dunkel" nowrap="nowrap" align="center">12:30</td>" & @CRLF & _ " <td class="dunkel" align="right"><a href="/teams/juventus/">Juventus</a></td>" & @CRLF & _ " <td class="dunkel" align="center"> - </td>" & @CRLF & _ " <td class="dunkel"><a href="/teams/tottenham-hotspur/">Tottenham Hotspur</a></td>" & @CRLF & _ " <td class="dunkel" align="center" nowrap>" & @CRLF & _ " -:- </td>" & @CRLF & _ " <td class="dunkel" align="center">" & @CRLF & _ " <img src="https://s.hs-data.com/bilder/shared/live/4.png">" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " " & @CRLF & _ " <tr>" & @CRLF & _ " <td class="hell" nowrap="nowrap" align="center">13:00</td>" & @CRLF & _ " <td class="hell" align="right"><a href="/teams/gillingham-fc/">Gillingham FC</a></td>" & @CRLF & _ " <td class="hell" align="center"> - </td>" & @CRLF & _ " <td class="hell"><a href="/teams/millwall-fc/">Millwall FC</a></td>" & @CRLF & _ " <td class="hell" align="center" nowrap>" & @CRLF & _ " -:- </td>" & @CRLF & _ " <td class="hell" align="center">" & @CRLF & _ " <img src="https://s.hs-data.com/bilder/shared/live/4.png">" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " " & @CRLF & _ " <tr>" & @CRLF & _ " <td class="dunkel" nowrap="nowrap" align="center">13:00</td>" & @CRLF & _ " <td class="dunkel" align="right"><a href="/teams/sv-lippstadt-08/">SV Lippstadt 08</a></td>" & @CRLF & _ " <td class="dunkel" align="center"> - </td>" & @CRLF & _ " <td class="dunkel"><a href="/teams/ksv-baunatal/">KSV Baunatal</a></td>" & @CRLF & _ " <td class="dunkel" align="center" nowrap>" & @CRLF & _ " -:- </td>" & @CRLF & _ " <td class="dunkel" align="center">" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " " & @CRLF & _ " <tr>" & @CRLF & _ " <td class="hell" nowrap="nowrap" align="center">13:00</td>" & @CRLF & _ " <td class="hell" align="right"><a href="/teams/sportfreunde-lotte/">Sportfreunde Lotte</a></td>" & @CRLF & _ " <td class="hell" align="center"> - </td>" & @CRLF & _ " <td class="hell"><a href="/teams/werder-bremen-ii/">Werder Bremen II</a></td>" & @CRLF & _ " <td class="hell" align="center" nowrap>" & @CRLF & _ " -:- </td>" & @CRLF & _ " <td class="hell" align="center">" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " " & @CRLF & _ " <tr>" & @CRLF & _ " <td class="dunkel" nowrap="nowrap" align="center">13:30</td>" & @CRLF & _ " <td class="dunkel" align="right"><a href="/teams/holstein-kiel/">Holstein Kiel</a></td>" & @CRLF & _ " <td class="dunkel" align="center"> - </td>" & @CRLF & _ " <td class="dunkel"><a href="/teams/sheffield-wednesday/">Sheffield Wednesday</a></td>" & @CRLF & _ " <td class="dunkel" align="center" nowrap>" & @CRLF & _ " <a href="/report/freundschaft-vereine-2019-kalenderwoche-holstein-kiel-sheffield-wednesday/" title=" Holstein Kiel - Sheffield Wednesday">-:- </a>" & @CRLF & _ " </td>" & @CRLF & _ " <td class="dunkel" align="center">" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " " & @CRLF & _ " <tr>" & @CRLF & _ " <td class="hell" nowrap="nowrap" align="center">14:00</td>" & @CRLF & _ " <td class="hell" align="right"><a href="/teams/sc-verl/">SC Verl</a></td>" & @CRLF & _ " <td class="hell" align="center"> - </td>" & @CRLF & _ " <td class="hell"><a href="/teams/arminia-bielefeld/">Arminia Bielefeld</a></td>" & @CRLF & _ " <td class="hell" align="center" nowrap>" & @CRLF & _ " <a href="/report/freundschaft-vereine-2019-kalenderwoche-sc-verl-arminia-bielefeld/" title=" SC Verl - Arminia Bielefeld">-:- </a>" & @CRLF & _ " </td>" & @CRLF & _ " <td class="hell" align="center">" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " " & @CRLF & _ " <tr>" & @CRLF & _ " <td class="dunkel" nowrap="nowrap" align="center">14:00</td>" & @CRLF & _ " <td class="dunkel" align="right"><a href="/teams/shrewsbury-town/">Shrewsbury Town</a></td>" & @CRLF & _ " <td class="dunkel" align="center"> - </td>" & @CRLF & _ " <td class="dunkel"><a href="/teams/aston-villa/">Aston Villa</a></td>" & @CRLF & _ " <td class="dunkel" align="center" nowrap>" & @CRLF & _ " -:- </td>" & @CRLF & _ " <td class="dunkel" align="center">" & @CRLF & _ " <img src="https://s.hs-data.com/bilder/shared/live/4.png">" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " " & @CRLF & _ " <tr>" & @CRLF & _ " <td class="hell" nowrap="nowrap" align="center">14:00</td>" & @CRLF & _ " <td class="hell" align="right"><a href="/teams/standard-liege/">Standard Liège</a></td>" & @CRLF & _ " <td class="hell" align="center"> - </td>" & @CRLF & _ " <td class="hell"><a href="/teams/ogc-nice/">OGC Nice</a></td>" & @CRLF & _ " <td class="hell" align="center" nowrap>" & @CRLF & _ " -:- </td>" & @CRLF & _ " <td class="hell" align="center">" & @CRLF & _ " <img src="https://s.hs-data.com/bilder/shared/live/4.png">" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " " & @CRLF & _ " <tr>" & @CRLF & _ " <td class="dunkel" nowrap="nowrap" align="center">14:00</td>" & @CRLF & _ " <td class="dunkel" align="right"><a href="/teams/sv-wehen-wiesbaden/">SV Wehen Wiesbaden</a></td>" & @CRLF & _ " <td class="dunkel" align="center"> - </td>" & @CRLF & _ " <td class="dunkel"><a href="/teams/boavista/">Boavista</a></td>" & @CRLF & _ " <td class="dunkel" align="center" nowrap>" & @CRLF & _ " -:- </td>" & @CRLF & _ " <td class="dunkel" align="center">" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " " & @CRLF & _ " <tr>" & @CRLF & _ " <td class="hell" nowrap="nowrap" align="center">15:00</td>" & @CRLF & _ " <td class="hell" align="right"><a href="/teams/1-fsv-mainz-05/">1. FSV Mainz 05</a></td>" & @CRLF & _ " <td class="hell" align="center"> - </td>" & @CRLF & _ " <td class="hell"><a href="/teams/jahn-regensburg/">Jahn Regensburg</a></td>" & @CRLF & _ " <td class="hell" align="center" nowrap>" & @CRLF & _ " -:- </td>" & @CRLF & _ " <td class="hell" align="center">" & @CRLF & _ " <img src="https://s.hs-data.com/bilder/shared/live/4.png">" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " " & @CRLF & _ " <tr>" & @CRLF & _ " <td class="dunkel" nowrap="nowrap" align="center">15:00</td>" & @CRLF & _ " <td class="dunkel" align="right"><a href="/teams/rangers-fc/">Rangers FC</a></td>" & @CRLF & _ " <td class="dunkel" align="center"> - </td>" & @CRLF & _ " <td class="dunkel"><a href="/teams/blackburn-rovers/">Blackburn Rovers</a></td>" & @CRLF & _ " <td class="dunkel" align="center" nowrap>" & @CRLF & _ " -:- </td>" & @CRLF & _ " <td class="dunkel" align="center">" & @CRLF & _ " <img src="https://s.hs-data.com/bilder/shared/live/4.png">" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " " & @CRLF & _ " <tr>" & @CRLF & _ " <td class="hell" nowrap="nowrap" align="center">15:00</td>" & @CRLF & _ " <td class="hell" align="right"><a href="/teams/kvc-westerlo/">KVC Westerlo</a></td>" & @CRLF & _ " <td class="hell" align="center"> - </td>" & @CRLF & _ " <td class="hell"><a href="/teams/krc-genk/">KRC Genk</a></td>" & @CRLF & _ " <td class="hell" align="center" nowrap>" & @CRLF & _ " -:- </td>" & @CRLF & _ " <td class="hell" align="center">" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " " & @CRLF & _ " <tr>" & @CRLF & _ " <td class="dunkel" nowrap="nowrap" align="center">16:00</td>" & @CRLF & _ " <td class="dunkel" align="right"><a href="/teams/atalanta/">Atalanta</a></td>" & @CRLF & _ " <td class="dunkel" align="center"> - </td>" & @CRLF & _ " <td class="dunkel"><a href="/teams/ac-renate/">AC Renate</a></td>" & @CRLF & _ " <td class="dunkel" align="center" nowrap>" & @CRLF & _ " -:- </td>" & @CRLF & _ " <td class="dunkel" align="center">" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " " & @CRLF & _ " <tr>" & @CRLF & _ " <td class="hell" nowrap="nowrap" align="center">16:00</td>" & @CRLF & _ " <td class="hell" align="right"><a href="/teams/lazio-roma/">Lazio Roma</a></td>" & @CRLF & _ " <td class="hell" align="center"> - </td>" & @CRLF & _ " <td class="hell"><a href="/teams/unione-triestina/">Unione Triestina</a></td>" & @CRLF & _ " <td class="hell" align="center" nowrap>" & @CRLF & _ " -:- </td>" & @CRLF & _ " <td class="hell" align="center">" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " " & @CRLF & _ " <tr>" & @CRLF & _ " <td class="dunkel" nowrap="nowrap" align="center">16:00</td>" & @CRLF & _ " <td class="dunkel" align="right"><a href="/teams/spal-2013-ferrara/">SPAL 2013 Ferrara</a></td>" & @CRLF & _ " <td class="dunkel" align="center"> - </td>" & @CRLF & _ " <td class="dunkel"><a href="/teams/pordenone-calcio/">Pordenone Calcio</a></td>" & @CRLF & _ " <td class="dunkel" align="center" nowrap>" & @CRLF & _ " -:- </td>" & @CRLF & _ " <td class="dunkel" align="center">" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @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