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

/
/
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)^(?<pos>.{4})\s(?<naam>.{25})\s(?<plaats>.{25})\s(?<tijd>.{8})" Local $sString = " 25 Gerry Trimpe Middelburg 1:46:04" & @CRLF & _ " 26 Sylvia Glerum-witkam Delta Sport 1:46:35" & @CRLF & _ " 27 Annette de bot THOR 1:47:27" & @CRLF & _ " 28 Ernesta Verburg Dreischor 1:47:40" & @CRLF & _ " 29 Daniella Evers Middelburg 1:47:48" & @CRLF & _ " 30 Corine Poot Arnhem 1:48:05" & @CRLF & _ " 31 Lian Zorge Zierikzee 1:48:37" & @CRLF & _ " 32 Miranda Kwakkelaar Middelburg 1:50:42" & @CRLF & _ " 33 Lianne wijsman Delta Sport 1:51:17" & @CRLF & _ " 34 Esther Oldenburger Brielle 1:51:40" & @CRLF & _ " 35 Katinka Schotanus Kloetinge 1:51:47" & @CRLF & _ " 36 Heleen van der Linden PAC 1:52:04" & @CRLF & _ " 37 Cora Verheij Abbenbroek 1:54:22" & @CRLF & _ " 38 Connie Huibregtse Delta Sport 1:54:55" & @CRLF & _ " 39 Jacqueline Meijers AV '56 1:55:07" & @CRLF & _ " 40 Josien van Waarde Middelburg 1:55:52" & @CRLF & _ " 41 Liesbet Peeters Kasterlee 1:56:02" & @CRLF & _ " 42 Marianne zwart Helmond 1:56:41" & @CRLF & _ " 43 MariƎlle Lauwers Helmond 1:56:43" & @CRLF & _ " 44 Ieke de Jonge 's-Gravenhage 1:57:48" & @CRLF & _ " 45 Joke van Paassen Rockanje 1:58:00" & @CRLF & _ " 46 Mireille van der Veer Brielle 1:58:02" & @CRLF & _ " 47 Sylvia Verkaart Kapelle 1:58:33" & @CRLF & _ " 48 Lenneke Ruijsink AV '56 1:59:06" & @CRLF & _ " 49 Nicole Ehbel Steenbergen Nb 1:59:16" & @CRLF & _ " 50 Laila Heshof Steenbergen Nb 1:59:18" & @CRLF & _ " 51 Marleen Verboom Delta Sport 1:59:20" & @CRLF & _ " 52 Mandy Bootsma Strijen 2:00:16" & @CRLF & _ " 53 Debora Hampel- van Kapel Oud-Vossemeer 2:01:24" & @CRLF & _ " 54 Janneke van Westen Sint Philipsland 2:01:29" & @CRLF & _ " 55 Petra van den Doel Zierikzee 2:02:41" & @CRLF & _ " 56 Jolanda ter Steege Dinteloord 2:03:42" & @CRLF & _ " 57 Marleen Hozee Vlissingen 2:03:52" & @CRLF & _ " 58 Cynthia Janse Delta Sport 2:03:54" & @CRLF & _ " 59 Esther Brouwer Vlissingen 2:04:46" & @CRLF & _ " 60 Regine Boogert Middelburg 2:04:48" & @CRLF & _ " 61 Miriam Bijl Zuid-Beijerland 2:04:51" & @CRLF & _ " 62 Mariel Kers Dordrecht 2:18:43" & @CRLF & _ " 63 Pippi Langkous Scharendijke 2:23:26" & @CRLF & _ " 64 Monique Coppejans Nieuwdorp Zld 2:33:34" 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