Regular Expressions 101

Save & Share

  • Regex Version: ver. 1
  • Fork Regex
    ctrl+s
  • Add to Community Library

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)(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))" Local $sString = "cc14:e1d0:8636:b5fe:ed02:f308:c51b:b269" & @CRLF & _ "63e2:2a95:3ed0:f118:63d4:1f6d:e511:de13" & @CRLF & _ "2fdd:c32f:0358:ff64:da39:a7db:eb1f:fa94" & @CRLF & _ "e4df:0bdf:396c:56ef:fb1b:1207:c252:097c" & @CRLF & _ "a051:27e4:adef:3d55:a369:02c3:51de:ffd7" & @CRLF & _ "5fec:aff9:5978:0df9:3c8e:8095:1a8b:d513" & @CRLF & _ "dd3e:9802:1f77:2a0b:920b:88e7:5659:b0ac" & @CRLF & _ "3ff2:1f5c:9734:a0f1:338c:70d6:8a7b:40c2" & @CRLF & _ "e294:91e7:b044:daf1:b359:85fb:20ec:2c27" & @CRLF & _ "1b7c:b087:7f13:2be3:91fe:4ab1:b3f6:2c46" & @CRLF & _ "ad23:8fa2:da36:89ee:b9ec:c7eb:3037:0a84" & @CRLF & _ "f2a8:f88c:c0b8:8adf:a0d0:32e4:12ce:2d0d" & @CRLF & _ "aafe:fe3a:b6b7:9be9:ad2e:9400:100c:1759" & @CRLF & _ "15de:d06c:c69a:0bb7:3956:a99d:9b30:0b8c" & @CRLF & _ "fd1b:6def:0088:f055:b2ed:17d1:8f68:998a" & @CRLF & _ "6258:2b38:eb8b:9abf:6888:a88e:b016:3dec" & @CRLF & _ "fa16:99d3:afd3:c660:ede5:0e74:c499:6444" & @CRLF & _ "8e64:c77c:bd13:6264:8393:1675:bf47:668a" & @CRLF & _ "e861:f66e:8f9d:c133:b559:d9eb:8774:edce" & @CRLF & _ "efb8:6adf:a2ba:a311:af1c:caed:fd46:9738" 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