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 single character of: a, b, c or d
    [[ab][cd]]
  • 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]
  • Character class intersection
    [\w&&[^\d]]
  • 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
No Match

"
"
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)((?<A>\s(greater|less|earlier)\sth[a|e]n)((?<B>\sor equal)[s]?)?(\sto)?\s)(?<V>[^\s]+)?" Local $sString = "Check if the version of xpsviewer.exe is greater than or equal to 3.0.6920.7000" & @CRLF & _ "Check if OpenSSL 1.1.0 version is greater than or equal 1.1.0 and less than 1.1.0e" & @CRLF & _ "Check if Oracle VM VirtualBox version is greater than or equals to 3.2.0" & @CRLF & _ "Version of VLC Media Player less than or equal to 2.0.4" & @CRLF & _ "Check if Java SE Development Kit 1.6 version is less than or equal 6.0.1710" & @CRLF & _ "Version of VLC Media Player greater than or equal to 0.5.0 and less than or equal to 0.9.5" & @CRLF & _ "the version of cryptdlg.dll is less then 5.0.1558.6072" & @CRLF & _ "Check if the version of Microsoft.sqlserver.chainer.infrastructure.dll is less than 14.0.2000.63 and greater than 14.0.0" & @CRLF & _ "Check if OpenSSL version is less than or equals to 0.9.8.24 in VisualSVN Server" & @CRLF & _ "Determine if the version of JavaFX is less than 2.2.46 (JRE 1.7.0:update_6 and later)" & @CRLF & _ "Mozilla Firefox ESR version is less than 24.1 and greater than or equal to 24.x" & @CRLF & _ "Check if SQL Server instances with version less than 2009.100.4000.0 and greater than or equal 2009.100.2500.0" & @CRLF & _ "Excel 2000 SP3 or greater is installed" & @CRLF & _ "Mozilla Firefox version 3.5.x to 3.5.1 or less than 3.0.14" & @CRLF & _ "Check if ssleay32.dll 1.0.1 version is greater than or equal 1.0.1 and less than 1.0.1u on ProgramFilesDir (x86)" & @CRLF & _ "Check if SQL Server instances with version greater than or equal 2007.100.6000.0 and less than 2009.100.1600.1 exist" & @CRLF & _ "Check if outlook.exe version is greater than or equal to 16.0.8201.0000 and less than 16.0.8201.2213 (MSO 2016 Version 1705)" & @CRLF & _ "firefox DPKG is earlier than 0:32.0+build1-0ubuntu0.12.04.1" & @CRLF & _ "openjdk-7-jre-headless DPKG is earlier than 0:7u65-2.5.1-4ubuntu1~0.14.04.1" & @CRLF & _ "kvm DPKG is earlier than 84+dfsg-0ubuntu16+0.12.3+noroms+0ubuntu9.4" & @CRLF & _ "Check if the version of ssleay32.dll 0.9.1c before 0.9.8y ProgramFilesDir x86" & @CRLF & _ "Check if the version of OpenSSL 0.9.1c before 0.9.8s (32_bit)" & @CRLF & _ "Version of Wireshark is 1.4.x before 1.4.15, 1.6.x before 1.6.10, or 1.8.x before 1.8.2" & @CRLF & _ "Version of Wireshark is 1.8.x before 1.8.10 or 1.10.x before 1.10.2" & @CRLF & _ "Check if the version of PHP is less than 5.2.15 or 5.3.x before 5.3.4" & @CRLF & _ "" & @CRLF & _ "" 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