Regular Expressions 101

Save & Share

  • Regex Version: ver. 1
  • Update Regex
    ctrl+⇧+s
  • Save new 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)(?:(^[^:\r\n]+):?[\r\n]+|\G(?!^))\r?\n[^:\r\n]+ : ([^\r\n]+(?:\r?\n(?!.* : )[ \t]+[^\r\n]+)*)" Local $sString = "Windows IP Configuration" & @CRLF & _ "" & @CRLF & _ " Host Name . . . . . . . . . . . . : abcmyhost" & @CRLF & _ " Primary Dns Suffix . . . . . . . : parker.industries" & @CRLF & _ " Node Type . . . . . . . . . . . . : Hybrid-GLS" & @CRLF & _ " IP Routing Enabled. . . . . . . . : YES" & @CRLF & _ " WINS Proxy Enabled. . . . . . . . : YES" & @CRLF & _ " DNS Suffix Search List. . . . . . : parker1.industries" & @CRLF & _ " parker2.industries" & @CRLF & _ " parker3.industries" & @CRLF & _ " parker4.industries" & @CRLF & _ " parker5.industries" & @CRLF & _ " parker6.industries" & @CRLF & _ " parker7.industries" & @CRLF & _ " parker8.industries" & @CRLF & _ " parker9.industries" & @CRLF & _ " parker10.industries" & @CRLF & _ "" & @CRLF & _ "Ethernet adapter Ethernet 5:" & @CRLF & _ "" & @CRLF & _ " Connection-specific DNS Suffix . : parker.industries" & @CRLF & _ " Description . . . . . . . . . . . : Ready 2" & @CRLF & _ " Physical Address. . . . . . . . . : 60-11-11-31-09-XY" & @CRLF & _ " DHCP Enabled. . . . . . . . . . . : NO" & @CRLF & _ " Autoconfiguration Enabled . . . . : Yes" & @CRLF & _ " Link-local IPv6 Address . . . . . : AB80::11FG:1KI:LK9F:12N2%19(Preferred) " & @CRLF & _ " IPv4 Address. . . . . . . . . . . : 111.222.333.444(Preferred) " & @CRLF & _ " Subnet Mask . . . . . . . . . . . : 255.255.255.0" & @CRLF & _ " Lease Obtained. . . . . . . . . . : Monday, November 11, 2019 6:23:03 AM" & @CRLF & _ " Lease Expires . . . . . . . . . . : Wednesday, November 13, 2019 6:51:30 AM" & @CRLF & _ " Default Gateway . . . . . . . . . : 111.11.131.1" & @CRLF & _ " DHCP Server . . . . . . . . . . . : 111.22.144.199" & @CRLF & _ " DHCPv6 IAID . . . . . . . . . . . : 87244642462" & @CRLF & _ " DHCPv6 Client DUID. . . . . . . . : 00-01-02-03-04-05-06-07-08-09-10-11-E9-G7" & @CRLF & _ " DNS Servers . . . . . . . . . . . : 111.22.111.254 " & @CRLF & _ " 111.22.112.254" & @CRLF & _ " 111.33.113.254" & @CRLF & _ " 111.33.114.254" & @CRLF & _ " NetBIOS over Tcpip. . . . . . . . : Enabled" 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