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
No Match

r'''
'''
g

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 = "(│?\s{3,})*[├└]─{2} " Local $sString = "├── Blog" & @CRLF & _ "│ └── _v_images" & @CRLF & _ "├── Essay" & @CRLF & _ "│ └── Encryption&Trust" & @CRLF & _ "├── Hidden" & @CRLF & _ "│ └── _v_images" & @CRLF & _ "├── Life" & @CRLF & _ "│ ├── Cuisine" & @CRLF & _ "│ ├── Game" & @CRLF & _ "│ ├── Ideas" & @CRLF & _ "│ ├── Linguistic" & @CRLF & _ "│ │ └── English" & @CRLF & _ "│ └── Music" & @CRLF & _ "├── Other" & @CRLF & _ "│ └── _v_images" & @CRLF & _ "├── PWN" & @CRLF & _ "│ └── _v_images" & @CRLF & _ "├── Programme" & @CRLF & _ "│ └── _v_images" & @CRLF & _ "├── Work" & @CRLF & _ "│ ├── Database" & @CRLF & _ "│ ├── GUI" & @CRLF & _ "│ │ └── CSS" & @CRLF & _ "│ ├── Language" & @CRLF & _ "│ │ └── DocString" & @CRLF & _ "│ │ └── __pycache__" & @CRLF & _ "│ ├── Network" & @CRLF & _ "│ ├── OS" & @CRLF & _ "│ │ ├── Android" & @CRLF & _ "│ │ │ ├── BuildTools" & @CRLF & _ "│ │ │ ├── DevTools" & @CRLF & _ "│ │ │ ├── Permissions" & @CRLF & _ "│ │ │ ├── PropertiesLogs" & @CRLF & _ "│ │ │ ├── Signer" & @CRLF & _ "│ │ │ │ ├── META-INF" & @CRLF & _ "│ │ │ │ └── webview" & @CRLF & _ "│ │ │ │ ├── META-INF" & @CRLF & _ "│ │ │ │ ├── assets" & @CRLF & _ "│ │ │ │ │ └── stored-locales" & @CRLF & _ "│ │ │ │ │ └── weblayer" & @CRLF & _ "│ │ │ │ ├── lib" & @CRLF & _ "│ │ │ │ │ ├── arm64-v8a" & @CRLF & _ "│ │ │ │ │ └── armeabi-v7a" & @CRLF & _ "│ │ │ │ └── res" & @CRLF & _ "│ │ │ │ ├── anim" & @CRLF & _ "│ │ │ │ ├── anim-v21" & @CRLF & _ "│ │ │ │ ├── animator" & @CRLF & _ "│ │ │ │ ├── animator-v21" & @CRLF & _ "│ │ │ │ ├── color" & @CRLF & _ "│ │ │ │ ├── color-v21" & @CRLF & _ "│ │ │ │ ├── color-v23" & @CRLF & _ "│ │ │ │ ├── drawable" & @CRLF & _ "│ │ │ │ ├── drawable-hdpi-v4" & @CRLF & _ "│ │ │ │ ├── drawable-ldrtl-hdpi-v17" & @CRLF & _ "│ │ │ │ ├── drawable-ldrtl-v17" & @CRLF & _ "│ │ │ │ ├── drawable-ldrtl-xhdpi-v17" & @CRLF & _ "│ │ │ │ ├── drawable-ldrtl-xxhdpi-v17" & @CRLF & _ "│ │ │ │ ├── drawable-ldrtl-xxxhdpi-v17" & @CRLF & _ "│ │ │ │ ├── drawable-night-hdpi-v8" & @CRLF & _ "│ │ │ │ ├── drawable-night-v8" & @CRLF & _ "│ │ │ │ ├── drawable-night-xhdpi-v8" & @CRLF & _ "│ │ │ │ ├── drawable-night-xxhdpi-v8" & @CRLF & _ "│ │ │ │ ├── drawable-night-xxxhdpi-v8" & @CRLF & _ "│ │ │ │ ├── drawable-v21" & @CRLF & _ "│ │ │ │ ├── drawable-v23" & @CRLF & _ "│ │ │ │ ├── drawable-v4" & @CRLF & _ "│ │ │ │ ├── drawable-xhdpi-v4" & @CRLF & _ "│ │ │ │ ├── drawable-xxhdpi-v4" & @CRLF & _ "│ │ │ │ ├── drawable-xxxhdpi-v4" & @CRLF & _ "│ │ │ │ ├── font" & @CRLF & _ "│ │ │ │ ├── interpolator" & @CRLF & _ "│ │ │ │ ├── interpolator-v21" & @CRLF & _ "│ │ │ │ ├── layout" & @CRLF & _ "│ │ │ │ ├── layout-land" & @CRLF & _ "│ │ │ │ ├── layout-v21" & @CRLF & _ "│ │ │ │ ├── layout-v22" & @CRLF & _ "│ │ │ │ ├── layout-v26" & @CRLF & _ "│ │ │ │ ├── menu" & @CRLF & _ "│ │ │ │ ├── raw" & @CRLF & _ "│ │ │ │ └── xml" & @CRLF & _ "│ │ │ └── UID" & @CRLF & _ "│ │ └── Linux" & @CRLF & _ "│ ├── Presentation" & @CRLF & _ "│ │ ├── Diagram" & @CRLF & _ "│ │ ├── Slides" & @CRLF & _ "│ │ │ └── images" & @CRLF & _ "│ │ └── Writing" & @CRLF & _ "│ ├── Project" & @CRLF & _ "│ ├── RE" & @CRLF & _ "│ ├── Service" & @CRLF & _ "│ ├── Tool" & @CRLF & _ "│ │ ├── Diff" & @CRLF & _ "│ │ ├── File" & @CRLF & _ "│ │ ├── Frida" & @CRLF & _ "│ │ │ └── scripts" & @CRLF & _ "│ │ ├── Git" & @CRLF & _ "│ │ ├── IO" & @CRLF & _ "│ │ ├── Shell" & @CRLF & _ "│ │ └── Text" & @CRLF & _ "│ └── Virtualization" & @CRLF & _ "│ └── Docker" & @CRLF & _ "└── 随笔" & @CRLF & _ " └── _v_images" 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