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)^((?!V2).)*- Master\s*$" Local $sString = "AppMessages V2 - Dev" & @CRLF & _ "AppMessages V2 - Master" & @CRLF & _ "AWS - Octopus Release" & @CRLF & _ "Bellhop Model V2 - Dev" & @CRLF & _ "Bellhop Model V2 - Master" & @CRLF & _ "BellHop Services V2 - Dev" & @CRLF & _ "BellHop Services V2 - Master" & @CRLF & _ "BellHop V2 - Dev" & @CRLF & _ "BellHop V2 - Master" & @CRLF & _ "BSG Log4j Extras V2 - Dev" & @CRLF & _ "BSG Log4j Extras V2 - Master" & @CRLF & _ "BSG-BOM - Dev" & @CRLF & _ "BSG-BOM - Master" & @CRLF & _ "BSG-BOM V2 - Dev" & @CRLF & _ "BSG-BOM V2 - Master" & @CRLF & _ "Core Model V2 - Dev" & @CRLF & _ "Core Model V2 - Master" & @CRLF & _ "Core Services V2 - Dev" & @CRLF & _ "Core Services V2 - Master" & @CRLF & _ "DealerLocator - Dev" & @CRLF & _ "EMS Services V2 - Dev" & @CRLF & _ "EMS Services V2 - Master" & @CRLF & _ "Entitlements REST API V2 - Dev" & @CRLF & _ "Entitlements REST API V2 - Master" & @CRLF & _ "Entitlements Services V2 - Dev" & @CRLF & _ "Entitlements Services V2 - Master" & @CRLF & _ "Entitlements SOAP API V2 - Dev" & @CRLF & _ "Entitlements SOAP API V2 - Master" & @CRLF & _ "FlexNet Services - Dev" & @CRLF & _ "FlexNet Services - Master" & @CRLF & _ "GetNodeInfo BusSys-Build-Slave-01" & @CRLF & _ "GetNodeInfo BusSys_Corp_Build_Slave" & @CRLF & _ "GetNodeInfo Master" & @CRLF & _ "Laipac Services V2 - Dev" & @CRLF & _ "Laipac Services V2 - Master" & @CRLF & _ "LDK Services V2 - Dev" & @CRLF & _ "LDK Services V2 - Master" & @CRLF & _ "LicenseAdmin - Dev" & @CRLF & _ "LicenseAdmin - Master" & @CRLF & _ "List All Jobs" & @CRLF & _ "Lite Services V2 - Dev" & @CRLF & _ "Lite Services V2 - Master" & @CRLF & _ "LiteFlexNetIntegration V2 - Dev" & @CRLF & _ "LiteFlexNetIntegration V2 - Master" & @CRLF & _ "LiteIntegration - Dev" & @CRLF & _ "LiteIntegration - Master" & @CRLF & _ "Messaging Services V2 - Dev" & @CRLF & _ "Messaging Services V2 - Master" & @CRLF & _ "MTPConsumer - Dev" & @CRLF & _ "MTPConsumer - Master" & @CRLF & _ "OptionKeys - Dev" & @CRLF & _ "OptionKeys - Master" & @CRLF & _ "OptionKeysAPI - Dev" & @CRLF & _ "OptionKeysAPI - Master" & @CRLF & _ "Panther REST API V2 - Dev" & @CRLF & _ "Pools API V2 - Dev" & @CRLF & _ "Pools API V2 - Master" & @CRLF & _ "Pools Model V2 - Dev" & @CRLF & _ "Pools Model V2 - Master" & @CRLF & _ "Pools Services V2 - Dev" & @CRLF & _ "Pools Services V2 - Master" & @CRLF & _ "Preconfigured API V2 - Dev" & @CRLF & _ "Preconfigured API V2 - Master" & @CRLF & _ "SCL Client V2 - Dev" & @CRLF & _ "SCL Client V2 - Master" & @CRLF & _ "SentinelCloud Services V2 - Dev" & @CRLF & _ "SentinelCloud Services V2 - Master" & @CRLF & _ "SubscriptionManager V2 - Dev" & @CRLF & _ "SubscriptionManager V2 - Master" & @CRLF & _ "TermsOfService - Master" & @CRLF & _ "Test Support V2 - Dev" & @CRLF & _ "Test Support V2 - Master" & @CRLF & _ "Tid Services V2 - Dev" & @CRLF & _ "Tid Services V2 - Master" & @CRLF & _ "Upload templates to S3 - branch2Dev" & @CRLF & _ "Upload templates to S3 - Dev" & @CRLF & _ "Upload templates to S3 - Master" & @CRLF & _ "Upload templates to S3 - Test" & @CRLF & _ "VirtualWarehouse - Dev" & @CRLF & _ "VirtualWarehouse - Master" & @CRLF & _ "VirtualWarehouse Services V2 - Dev" & @CRLF & _ "VirtualWarehouse Services V2 - Master" & @CRLF & _ "VW Lite API - Dev" & @CRLF & _ "VW Lite API - Master" & @CRLF & _ "VW Remedy Events - Dev" & @CRLF & _ "VW Remedy Events - Master" & @CRLF & _ "VW Remedy Events Consumer - Dev" & @CRLF & _ "VW Remedy Events Consumer - Master" & @CRLF & _ "VW Remedy Events Lib - Dev" & @CRLF & _ "VW Remedy Events Lib - Master" & @CRLF & _ "VW Scheduled Tasks V2 - Dev" & @CRLF & _ "VW Scheduled Tasks V2 - Master" & @CRLF & _ "VW Sentinel V2 - Dev" & @CRLF & _ "VW Sentinel V2 - Master" & @CRLF & _ "VW Subscriptions V2 - Dev" & @CRLF & _ "VW Subscriptions V2 - Master" & @CRLF & _ "VW5 - Dev" & @CRLF & _ "VW5 - Master" & @CRLF & _ "WooCommerce API V2 - Dev" & @CRLF & _ "WooCommerce API V2 - Master" & @CRLF & _ "WooCommerce Model V2 - Dev" & @CRLF & _ "WooCommerce Model V2 - Master" & @CRLF & _ "WooCommerce Services V2 - Dev" & @CRLF & _ "WooCommerce Services V2 - Master" 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