Regular Expressions 101

Save & Manage Regex

  • Current Version: 1
  • Save & Share
  • Community Library

Flavor

  • PCRE2 (PHP)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java
  • .NET 7.0 (C#)
  • Rust
  • PCRE (Legacy)
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests
Sponsors
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
Processing...

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 = "(Ethernet [^a]*adapter) (Local[^:]+):\n*(( +[^\n]+\n)*)" Local $sString = "" & @CRLF & _ "Windows IP Configuration" & @CRLF & _ "" & @CRLF & _ " Host Name . . . . . . . . . . . . : Andrew-PC" & @CRLF & _ " Primary Dns Suffix . . . . . . . : " & @CRLF & _ " Node Type . . . . . . . . . . . . : Hybrid" & @CRLF & _ " IP Routing Enabled. . . . . . . . : No" & @CRLF & _ " WINS Proxy Enabled. . . . . . . . : No" & @CRLF & _ "" & @CRLF & _ "Ethernet adapter Local Area Connection:" & @CRLF & _ "" & @CRLF & _ " Connection-specific DNS Suffix . : " & @CRLF & _ " Description . . . . . . . . . . . : Realtek PCIe GBE Family Controller" & @CRLF & _ " Physical Address. . . . . . . . . : 00-24-1D-87-DE-E8" & @CRLF & _ " DHCP Enabled. . . . . . . . . . . : No" & @CRLF & _ " Autoconfiguration Enabled . . . . : Yes" & @CRLF & _ " Link-local IPv6 Address . . . . . : fe80::2d30:3157:776c:5d1%3(Preferred) " & @CRLF & _ " IPv4 Address. . . . . . . . . . . : 192.168.1.111(Preferred) " & @CRLF & _ " Subnet Mask . . . . . . . . . . . : 255.255.255.0" & @CRLF & _ " Default Gateway . . . . . . . . . : 192.168.1.1" & @CRLF & _ " DHCPv6 IAID . . . . . . . . . . . : 234890269" & @CRLF & _ " DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-1C-A8-DF-09-00-24-1D-87-DE-E6" & @CRLF & _ " DNS Servers . . . . . . . . . . . : 75.75.75.75" & @CRLF & _ " 75.75.76.76" & @CRLF & _ " NetBIOS over Tcpip. . . . . . . . : Enabled" & @CRLF & _ "" & @CRLF & _ "Ethernet adapter VMware Network Adapter VMnet1:" & @CRLF & _ "" & @CRLF & _ " Connection-specific DNS Suffix . : " & @CRLF & _ " Description . . . . . . . . . . . : VMware Virtual Ethernet Adapter for VMnet1" & @CRLF & _ " Physical Address. . . . . . . . . : 00-50-56-C0-00-01" & @CRLF & _ " DHCP Enabled. . . . . . . . . . . : Yes" & @CRLF & _ " Autoconfiguration Enabled . . . . : Yes" & @CRLF & _ " Link-local IPv6 Address . . . . . : fe80::7877:2883:1349:6d38%10(Preferred) " & @CRLF & _ " IPv4 Address. . . . . . . . . . . : 192.168.107.1(Preferred) " & @CRLF & _ " Subnet Mask . . . . . . . . . . . : 255.255.255.0" & @CRLF & _ " Lease Obtained. . . . . . . . . . : Friday, February 26, 2016 7:31:41 AM" & @CRLF & _ " Lease Expires . . . . . . . . . . : Friday, February 26, 2016 11:31:41 AM" & @CRLF & _ " Default Gateway . . . . . . . . . : " & @CRLF & _ " DHCP Server . . . . . . . . . . . : 192.168.107.254" & @CRLF & _ " DHCPv6 IAID . . . . . . . . . . . : 167792726" & @CRLF & _ " DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-1C-A8-DF-09-00-24-1D-87-DE-E6" & @CRLF & _ " DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1" & @CRLF & _ " fec0:0:0:ffff::2%1" & @CRLF & _ " fec0:0:0:ffff::3%1" & @CRLF & _ " NetBIOS over Tcpip. . . . . . . . : Enabled" & @CRLF & _ "" & @CRLF & _ "Ethernet adapter VMware Network Adapter VMnet8:" & @CRLF & _ "" & @CRLF & _ " Connection-specific DNS Suffix . : " & @CRLF & _ " Description . . . . . . . . . . . : VMware Virtual Ethernet Adapter for VMnet8" & @CRLF & _ " Physical Address. . . . . . . . . : 00-50-56-C0-00-08" & @CRLF & _ " DHCP Enabled. . . . . . . . . . . : Yes" & @CRLF & _ " Autoconfiguration Enabled . . . . : Yes" & @CRLF & _ " Link-local IPv6 Address . . . . . : fe80::c57b:b161:5ed3:76ae%12(Preferred) " & @CRLF & _ " IPv4 Address. . . . . . . . . . . : 192.168.88.1(Preferred) " & @CRLF & _ " Subnet Mask . . . . . . . . . . . : 255.255.255.0" & @CRLF & _ " Lease Obtained. . . . . . . . . . : Friday, February 26, 2016 7:31:34 AM" & @CRLF & _ " Lease Expires . . . . . . . . . . : Friday, February 26, 2016 11:31:33 AM" & @CRLF & _ " Default Gateway . . . . . . . . . : " & @CRLF & _ " DHCP Server . . . . . . . . . . . : 192.168.88.254" & @CRLF & _ " DHCPv6 IAID . . . . . . . . . . . : 201347158" & @CRLF & _ " DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-1C-A8-DF-09-00-24-1D-87-DE-E6" & @CRLF & _ " DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1" & @CRLF & _ " fec0:0:0:ffff::2%1" & @CRLF & _ " fec0:0:0:ffff::3%1" & @CRLF & _ " Primary WINS Server . . . . . . . : 192.168.88.2" & @CRLF & _ " NetBIOS over Tcpip. . . . . . . . : Enabled" & @CRLF & _ "" & @CRLF & _ "Tunnel adapter isatap.{9C26E507-7425-4DAB-BAC3-1E30E266D4DC}:" & @CRLF & _ "" & @CRLF & _ " Media State . . . . . . . . . . . : Media disconnected" & @CRLF & _ " Connection-specific DNS Suffix . : " & @CRLF & _ " Description . . . . . . . . . . . : Microsoft ISATAP Adapter" & @CRLF & _ " Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0" & @CRLF & _ " DHCP Enabled. . . . . . . . . . . : No" & @CRLF & _ " Autoconfiguration Enabled . . . . : Yes" & @CRLF & _ "" & @CRLF & _ "Tunnel adapter Teredo Tunneling Pseudo-Interface:" & @CRLF & _ "" & @CRLF & _ " Connection-specific DNS Suffix . : " & @CRLF & _ " Description . . . . . . . . . . . : Teredo Tunneling Pseudo-Interface" & @CRLF & _ " Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0" & @CRLF & _ " DHCP Enabled. . . . . . . . . . . : No" & @CRLF & _ " Autoconfiguration Enabled . . . . : Yes" & @CRLF & _ " IPv6 Address. . . . . . . . . . . : 2001:0:9d38:6ab8:c9e:283d:9d3b:997e(Preferred) " & @CRLF & _ " Link-local IPv6 Address . . . . . : fe80::c9e:283d:9d3b:997e%2(Preferred) " & @CRLF & _ " Default Gateway . . . . . . . . . : ::" & @CRLF & _ " DHCPv6 IAID . . . . . . . . . . . : 150994944" & @CRLF & _ " DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-1C-A8-DF-09-00-24-1D-87-DE-E6" & @CRLF & _ " NetBIOS over Tcpip. . . . . . . . : Disabled" & @CRLF & _ "" & @CRLF & _ "Tunnel adapter isatap.{403315D9-A3E6-46A0-8CA5-6372C24FF823}:" & @CRLF & _ "" & @CRLF & _ " Media State . . . . . . . . . . . : Media disconnected" & @CRLF & _ " Connection-specific DNS Suffix . : " & @CRLF & _ " Description . . . . . . . . . . . : Microsoft ISATAP Adapter #2" & @CRLF & _ " Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0" & @CRLF & _ " DHCP Enabled. . . . . . . . . . . : No" & @CRLF & _ " Autoconfiguration Enabled . . . . : Yes" & @CRLF & _ "" & @CRLF & _ "Tunnel adapter isatap.{B5708232-0F11-410B-930D-39D3A7908EAF}:" & @CRLF & _ "" & @CRLF & _ " Media State . . . . . . . . . . . : Media disconnected" & @CRLF & _ " Connection-specific DNS Suffix . : " & @CRLF & _ " Description . . . . . . . . . . . : Microsoft ISATAP Adapter #3" & @CRLF & _ " Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0" & @CRLF & _ " DHCP Enabled. . . . . . . . . . . : No" & @CRLF & _ " Autoconfiguration Enabled . . . . : Yes" & @CRLF & _ "" & @CRLF & _ "Windows IP Configuration" & @CRLF & _ "" & @CRLF & _ " Host Name . . . . . . . . . . . . : Landen-Laptop" & @CRLF & _ " Primary Dns Suffix . . . . . . . : " & @CRLF & _ " Node Type . . . . . . . . . . . . : Hybrid" & @CRLF & _ " IP Routing Enabled. . . . . . . . : No" & @CRLF & _ " WINS Proxy Enabled. . . . . . . . : No" & @CRLF & _ "" & @CRLF & _ "Wireless LAN adapter Wireless Network Connection:" & @CRLF & _ "" & @CRLF & _ " Media State . . . . . . . . . . . : Media disconnected" & @CRLF & _ " Connection-specific DNS Suffix . : " & @CRLF & _ " Description . . . . . . . . . . . : Broadcom 802.11n Network Adapter" & @CRLF & _ " Physical Address. . . . . . . . . : 00-1B-B1-AB-7E-74" & @CRLF & _ " DHCP Enabled. . . . . . . . . . . : Yes" & @CRLF & _ " Autoconfiguration Enabled . . . . : Yes" & @CRLF & _ "" & @CRLF & _ "Ethernet adapter Local Area Connection:" & @CRLF & _ "" & @CRLF & _ " Connection-specific DNS Suffix . : " & @CRLF & _ " Description . . . . . . . . . . . : Realtek PCIe GBE Family Controller" & @CRLF & _ " Physical Address. . . . . . . . . : E8-11-32-2E-26-23" & @CRLF & _ " DHCP Enabled. . . . . . . . . . . : Yes" & @CRLF & _ " Autoconfiguration Enabled . . . . : Yes" & @CRLF & _ " Link-local IPv6 Address . . . . . : fe80::edba:a079:1244:b4b3%13(Preferred) " & @CRLF & _ " IPv4 Address. . . . . . . . . . . : 192.168.0.106(Preferred) " & @CRLF & _ " Subnet Mask . . . . . . . . . . . : 255.255.255.0" & @CRLF & _ " Lease Obtained. . . . . . . . . . : Friday, February 26, 2016 10:40:56 AM" & @CRLF & _ " Lease Expires . . . . . . . . . . : Friday, February 26, 2016 12:40:55 PM" & @CRLF & _ " Default Gateway . . . . . . . . . : 192.168.0.11" & @CRLF & _ " DHCP Server . . . . . . . . . . . : 192.168.0.11" & @CRLF & _ " DHCPv6 IAID . . . . . . . . . . . : 300421426" & @CRLF & _ " DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-1E-50-43-28-E8-11-32-2E-26-22" & @CRLF & _ " DNS Servers . . . . . . . . . . . : 208.67.222.123" & @CRLF & _ " 208.67.220.123" & @CRLF & _ " NetBIOS over Tcpip. . . . . . . . : Enabled" & @CRLF & _ "" & @CRLF & _ "Ethernet adapter Bluetooth Network Connection:" & @CRLF & _ "" & @CRLF & _ " Media State . . . . . . . . . . . : Media disconnected" & @CRLF & _ " Connection-specific DNS Suffix . : " & @CRLF & _ " Description . . . . . . . . . . . : Bluetooth Device (Personal Area Network)" & @CRLF & _ " Physical Address. . . . . . . . . : 00-1B-B1-FB-34-76" & @CRLF & _ " DHCP Enabled. . . . . . . . . . . : Yes" & @CRLF & _ " Autoconfiguration Enabled . . . . : Yes" & @CRLF & _ "" & @CRLF & _ "Tunnel adapter isatap.{1F3D3DAD-1D52-4329-9C52-58CD7B54C86A}:" & @CRLF & _ "" & @CRLF & _ " Media State . . . . . . . . . . . : Media disconnected" & @CRLF & _ " Connection-specific DNS Suffix . : " & @CRLF & _ " Description . . . . . . . . . . . : Microsoft ISATAP Adapter" & @CRLF & _ " Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0" & @CRLF & _ " DHCP Enabled. . . . . . . . . . . : No" & @CRLF & _ " Autoconfiguration Enabled . . . . : Yes" & @CRLF & _ "" & @CRLF & _ "Tunnel adapter isatap.{25CBD760-74ED-4CE7-8E1B-328A12335E7A}:" & @CRLF & _ "" & @CRLF & _ " Media State . . . . . . . . . . . : Media disconnected" & @CRLF & _ " Connection-specific DNS Suffix . : " & @CRLF & _ " Description . . . . . . . . . . . : Microsoft ISATAP Adapter #2" & @CRLF & _ " Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0" & @CRLF & _ " DHCP Enabled. . . . . . . . . . . : No" & @CRLF & _ " Autoconfiguration Enabled . . . . : Yes" & @CRLF & _ "" & @CRLF & _ "Tunnel adapter isatap.{4AC4D1F9-A993-4CBE-9CB8-414BD6853831}:" & @CRLF & _ "" & @CRLF & _ " Media State . . . . . . . . . . . : Media disconnected" & @CRLF & _ " Connection-specific DNS Suffix . : " & @CRLF & _ " Description . . . . . . . . . . . : Microsoft ISATAP Adapter #3" & @CRLF & _ " Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0" & @CRLF & _ " DHCP Enabled. . . . . . . . . . . : No" & @CRLF & _ " Autoconfiguration Enabled . . . . : Yes" & @CRLF & _ "" & @CRLF & _ "Windows IP Configuration" & @CRLF & _ " Host Name . . . . . . . . . . . . : PChuck1" & @CRLF & _ " Primary Dns Suffix . . . . . . . : " & @CRLF & _ " Node Type . . . . . . . . . . . . : Broadcast" & @CRLF & _ " IP Routing Enabled. . . . . . . . : No" & @CRLF & _ " WINS Proxy Enabled. . . . . . . . : No" & @CRLF & _ " DNS Suffix Search List. . . . . . : pchuck.net" & @CRLF & _ "" & @CRLF & _ "Ethernet adapter Local Area Connection:" & @CRLF & _ " Connection-specific DNS Suffix . : " & @CRLF & _ " Description . . . . . . . . . . . : 3Com EtherLink XL 10/100 PCI For Complete PC Management NIC (3C905C-TX)" & @CRLF & _ " Physical Address. . . . . . . . . : 00-04-76-D7-C5-6B" & @CRLF & _ " Dhcp Enabled. . . . . . . . . . . : Yes" & @CRLF & _ " Autoconfiguration Enabled . . . . : Yes" & @CRLF & _ " IP Address. . . . . . . . . . . . : 192.168.1.59" & @CRLF & _ " Subnet Mask . . . . . . . . . . . : 255.255.255.0" & @CRLF & _ " Default Gateway . . . . . . . . . : 192.168.1.1" & @CRLF & _ " DHCP Server . . . . . . . . . . . : 192.168.1.1" & @CRLF & _ " DNS Servers . . . . . . . . . . . : 192.168.1.11" & @CRLF & _ " 192.168.1.33" & @CRLF & _ " Lease Obtained. . . . . . . . . . : Wednesday, April 16, 2003 11:19:12" & @CRLF & _ " Lease Expires . . . . . . . . . . : Wednesday, April 23, 2003 11:19:12" & @CRLF & _ "" & @CRLF & _ "Windows IP Configuration" & @CRLF & _ " Host Name . . . . . . . . . . . . : PChuck2" & @CRLF & _ " Primary Dns Suffix . . . . . . . : " & @CRLF & _ " Node Type . . . . . . . . . . . . : Hybrid" & @CRLF & _ " IP Routing Enabled. . . . . . . . : No" & @CRLF & _ " WINS Proxy Enabled. . . . . . . . : No" & @CRLF & _ " DNS Suffix Search List. . . . . . : pchuck.net" & @CRLF & _ "Ethernet adapter Local Area Connection:" & @CRLF & _ " Connection-specific DNS Suffix . : " & @CRLF & _ " Description . . . . . . . . . . . : 3Com EtherLink XL 10/100 PCI For Complete PC Management NIC (3C905C-TX)" & @CRLF & _ " Physical Address. . . . . . . . . : 00-04-76-D7-76-BC" & @CRLF & _ " Dhcp Enabled. . . . . . . . . . . : Yes" & @CRLF & _ " Autoconfiguration Enabled . . . . : Yes" & @CRLF & _ " IP Address. . . . . . . . . . . . : 192.168.1.51" & @CRLF & _ " Subnet Mask . . . . . . . . . . . : 255.255.255.0" & @CRLF & _ " Default Gateway . . . . . . . . . : 192.168.1.1" & @CRLF & _ " DHCP Server . . . . . . . . . . . : 192.168.1.1" & @CRLF & _ " DNS Servers . . . . . . . . . . . : 192.168.1.11" & @CRLF & _ " 192.168.1.33" & @CRLF & _ " Primary WINS Server . . . . . . . : 192.168.1.1" & @CRLF & _ " Lease Obtained. . . . . . . . . . : Wednesday, April 16, 2003 11:53:45" & @CRLF & _ " Lease Expires . . . . . . . . . . : Wednesday, April 23, 2003 11:53:45" 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