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

/
/
gim

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 = "(?im)([[:blank:]][[:xdigit:]]{2}-[[:xdigit:]]{2}-[[:xdigit:]]{2}-[[:xdigit:]]{2}-[[:xdigit:]]{2}-[[:xdigit:]]{2})$" Local $sString = "Windows-IP-Konfiguration" & @CRLF & _ "" & @CRLF & _ " Hostname . . . . . . . . . . . . : tarox" & @CRLF & _ " Primäres DNS-Suffix . . . . . . . :" & @CRLF & _ " Knotentyp . . . . . . . . . . . . : Hybrid" & @CRLF & _ " IP-Routing aktiviert . . . . . . : Nein" & @CRLF & _ " WINS-Proxy aktiviert . . . . . . : Nein" & @CRLF & _ "" & @CRLF & _ "Ethernet-Adapter Bluetooth-Netzwerkverbindung:" & @CRLF & _ "" & @CRLF & _ " Medienstatus. . . . . . . . . . . : Medium getrennt" & @CRLF & _ " Verbindungsspezifisches DNS-Suffix:" & @CRLF & _ " Beschreibung. . . . . . . . . . . : Bluetooth-Gerät (PAN)" & @CRLF & _ " Physikalische Adresse . . . . . . : 00-25-D3-B7-CF-FE" & @CRLF & _ " DHCP aktiviert. . . . . . . . . . : Ja" & @CRLF & _ " Autokonfiguration aktiviert . . . : Ja" & @CRLF & _ "" & @CRLF & _ "Ethernet-Adapter OpenVPN frenzy:" & @CRLF & _ "" & @CRLF & _ " Medienstatus. . . . . . . . . . . : Medium getrennt" & @CRLF & _ " Verbindungsspezifisches DNS-Suffix:" & @CRLF & _ " Beschreibung. . . . . . . . . . . : TAP-Windows Adapter V9 #2" & @CRLF & _ " Physikalische Adresse . . . . . . : 00-FF-BE-A2-27-2D" & @CRLF & _ " DHCP aktiviert. . . . . . . . . . : Ja" & @CRLF & _ " Autokonfiguration aktiviert . . . : Ja" & @CRLF & _ "" & @CRLF & _ "Ethernet-Adapter OpenVPN megatron:" & @CRLF & _ "" & @CRLF & _ " Medienstatus. . . . . . . . . . . : Medium getrennt" & @CRLF & _ " Verbindungsspezifisches DNS-Suffix:" & @CRLF & _ " Beschreibung. . . . . . . . . . . : TAP-Windows Adapter V9" & @CRLF & _ " Physikalische Adresse . . . . . . : 00-FF-5B-6B-65-09" & @CRLF & _ " DHCP aktiviert. . . . . . . . . . : Ja" & @CRLF & _ " Autokonfiguration aktiviert . . . : Ja" & @CRLF & _ "" & @CRLF & _ "Drahtlos-LAN-Adapter Drahtlosnetzwerkverbindung:" & @CRLF & _ "" & @CRLF & _ " Medienstatus. . . . . . . . . . . : Medium getrennt" & @CRLF & _ " Verbindungsspezifisches DNS-Suffix: stollfuss.net" & @CRLF & _ " Beschreibung. . . . . . . . . . . : Intel(R) Centrino(R) Wireless-N 1000" & @CRLF & _ " Physikalische Adresse . . . . . . : 8C-A9-82-2E-0C-FE" & @CRLF & _ " DHCP aktiviert. . . . . . . . . . : Ja" & @CRLF & _ " Autokonfiguration aktiviert . . . : Ja" & @CRLF & _ "" & @CRLF & _ "Ethernet-Adapter LAN-Verbindung:" & @CRLF & _ "" & @CRLF & _ " Verbindungsspezifisches DNS-Suffix:" & @CRLF & _ " Beschreibung. . . . . . . . . . . : Atheros AR8121/AR8113/AR8114 PCI-E Ethernet Controller(NDIS6.20)" & @CRLF & _ " Physikalische Adresse . . . . . . : 70-71-BC-D6-BF-77" & @CRLF & _ " DHCP aktiviert. . . . . . . . . . : Nein" & @CRLF & _ " Autokonfiguration aktiviert . . . : Ja" & @CRLF & _ " Verbindungslokale IPv6-Adresse . : fe80::8517:61e4:94f0:173a%11(Bevorzugt)" & @CRLF & _ " IPv4-Adresse . . . . . . . . . . : 192.168.2.10(Bevorzugt)" & @CRLF & _ " Subnetzmaske . . . . . . . . . . : 255.255.255.0" & @CRLF & _ " Standardgateway . . . . . . . . . : 192.168.2.1" & @CRLF & _ " DHCPv6-IAID . . . . . . . . . . . : 242250172" & @CRLF & _ " DHCPv6-Client-DUID. . . . . . . . : 00-01-00-01-1C-64-1F-D5-70-71-BC-D6-BF-77" & @CRLF & _ " DNS-Server . . . . . . . . . . . : 192.168.2.1" & @CRLF & _ " NetBIOS über TCP/IP . . . . . . . : Aktiviert" & @CRLF & _ "" & @CRLF & _ "Tunneladapter isatap.stollfuss.net:" & @CRLF & _ "" & @CRLF & _ " Medienstatus. . . . . . . . . . . : Medium getrennt" & @CRLF & _ " Verbindungsspezifisches DNS-Suffix:" & @CRLF & _ " Beschreibung. . . . . . . . . . . : Microsoft-ISATAP-Adapter" & @CRLF & _ " Physikalische Adresse . . . . . . : 00-00-00-00-00-00-00-E0" & @CRLF & _ " DHCP aktiviert. . . . . . . . . . : Nein" & @CRLF & _ " Autokonfiguration aktiviert . . . : Ja" & @CRLF & _ "" & @CRLF & _ "Tunneladapter LAN-Verbindung* 11:" & @CRLF & _ "" & @CRLF & _ " Medienstatus. . . . . . . . . . . : Medium getrennt" & @CRLF & _ " Verbindungsspezifisches DNS-Suffix:" & @CRLF & _ " Beschreibung. . . . . . . . . . . : Teredo Tunneling Pseudo-Interface" & @CRLF & _ " Physikalische Adresse . . . . . . : 00-00-00-00-00-00-00-E0" & @CRLF & _ " DHCP aktiviert. . . . . . . . . . : Nein" & @CRLF & _ " Autokonfiguration aktiviert . . . : Ja" & @CRLF & _ "" & @CRLF & _ "Tunneladapter isatap.{5B6B6509-4089-4D8B-873E-6C9BCECA9C38}:" & @CRLF & _ "" & @CRLF & _ " Medienstatus. . . . . . . . . . . : Medium getrennt" & @CRLF & _ " Verbindungsspezifisches DNS-Suffix:" & @CRLF & _ " Beschreibung. . . . . . . . . . . : Microsoft-ISATAP-Adapter #2" & @CRLF & _ " Physikalische Adresse . . . . . . : 00-00-00-00-00-00-00-E0" & @CRLF & _ " DHCP aktiviert. . . . . . . . . . : Nein" & @CRLF & _ " Autokonfiguration aktiviert . . . : Ja" & @CRLF & _ "" & @CRLF & _ "Tunneladapter Reusable ISATAP Interface {36BFBE43-5F0F-42E3-89B3-B581DF95C122}:" & @CRLF & _ "" & @CRLF & _ " Medienstatus. . . . . . . . . . . : Medium getrennt" & @CRLF & _ " Verbindungsspezifisches DNS-Suffix:" & @CRLF & _ " Beschreibung. . . . . . . . . . . : Microsoft-ISATAP-Adapter #3" & @CRLF & _ " Physikalische Adresse . . . . . . : 00-00-00-00-00-00-00-E0" & @CRLF & _ " DHCP aktiviert. . . . . . . . . . : Nein" & @CRLF & _ " Autokonfiguration aktiviert . . . : Ja" & @CRLF & _ "" & @CRLF & _ "Tunneladapter isatap.{BE04D9C2-65F1-4777-9918-1CFEBAED5268}:" & @CRLF & _ "" & @CRLF & _ " Medienstatus. . . . . . . . . . . : Medium getrennt" & @CRLF & _ " Verbindungsspezifisches DNS-Suffix:" & @CRLF & _ " Beschreibung. . . . . . . . . . . : Microsoft-ISATAP-Adapter #4" & @CRLF & _ " Physikalische Adresse . . . . . . : 00-00-00-00-00-00-00-E0" & @CRLF & _ " DHCP aktiviert. . . . . . . . . . : Nein" & @CRLF & _ " Autokonfiguration aktiviert . . . : Ja" & @CRLF & _ "" & @CRLF & _ "Tunneladapter Reusable ISATAP Interface {A887E6BC-C744-4C0E-A17A-70E04B3DC3E2}:" & @CRLF & _ "" & @CRLF & _ " Medienstatus. . . . . . . . . . . : Medium getrennt" & @CRLF & _ " Verbindungsspezifisches DNS-Suffix:" & @CRLF & _ " Beschreibung. . . . . . . . . . . : Microsoft-ISATAP-Adapter #5" & @CRLF & _ " Physikalische Adresse . . . . . . : 00-00-00-00-00-00-00-E0" & @CRLF & _ " DHCP aktiviert. . . . . . . . . . : Nein" & @CRLF & _ " Autokonfiguration aktiviert . . . : Ja" & @CRLF & _ "" & @CRLF & _ "Tunneladapter isatap.{BEA2272D-AC7D-47E1-A3A4-D7273CF9CAFD}:" & @CRLF & _ "" & @CRLF & _ " Medienstatus. . . . . . . . . . . : Medium getrennt" & @CRLF & _ " Verbindungsspezifisches DNS-Suffix:" & @CRLF & _ " Beschreibung. . . . . . . . . . . : Microsoft-ISATAP-Adapter #6" & @CRLF & _ " Physikalische Adresse . . . . . . : 00-00-00-00-00-00-00-E0" & @CRLF & _ " DHCP aktiviert. . . . . . . . . . : Nein" & @CRLF & _ " Autokonfiguration aktiviert . . . : Ja" & @CRLF & _ "" & @CRLF & _ "Tunneladapter isatap.{20DD8A4C-A552-43A5-9B81-ABA8D73754B3}:" & @CRLF & _ "" & @CRLF & _ " Medienstatus. . . . . . . . . . . : Medium getrennt" & @CRLF & _ " Verbindungsspezifisches DNS-Suffix:" & @CRLF & _ " Beschreibung. . . . . . . . . . . : Microsoft-ISATAP-Adapter #7" & @CRLF & _ " Physikalische Adresse . . . . . . : 00-00-00-00-00-00-00-E0" & @CRLF & _ " DHCP aktiviert. . . . . . . . . . : Nein" & @CRLF & _ " Autokonfiguration aktiviert . . . : Ja" 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