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)^((\.{2}\\)+|(\.?\\)?).+" Local $sString = "..\meeting_minutes.txt" & @CRLF & _ "..\..\profile.txt" & @CRLF & _ "Reports\2023\summary.txt" & @CRLF & _ "\Reports\2023\summary.txt" & @CRLF & _ ".\Reports\2023\summary.txt" & @CRLF & _ "..\Projects\project_a.docx" & @CRLF & _ "..\Projects\project a.docx" & @CRLF & _ ".\my_file.txt" & @CRLF & _ ".\my file.txt" & @CRLF & _ "..\..\data" & @CRLF & _ "..\Music#a\file.mp3" & @CRLF & _ "..\Music[Genre]\file.mp3" & @CRLF & _ "..\Music(Genre)\file.mp3" & @CRLF & _ "..\Music-Hardcore-Metal\file.mp3" & @CRLF & _ "..\Documents\My+File.xlsx" & @CRLF & _ "..\Documents\Some{Document}.py" & @CRLF & _ "..\Files\Afilewithweird;Characters'`.doc" & @CRLF & _ "..\Music#^@!()-+{};',.`~a\file.mp3" & @CRLF & _ "..\.." & @CRLF & _ "..\..\Final" & @CRLF & _ "." & @CRLF & _ ".\..\Soils" & @CRLF & _ "..\..\.\Final\..\Shapefiles\.\Landuse" & @CRLF & _ "./data-files/geological/EQs_last_week_of_2021.csv../data-files/geological/" & @CRLF & _ "EQs_last_week_of_2021.csv../../data-files/EQs_last_week_of_2021.csv../../../data-files/" & @CRLF & _ "EQs_last_week_of_2021.csv../../../data-files/geological/EQs_last_week_of_2021.csv" & @CRLF & _ "../pictures/file.jpg" & @CRLF & _ ".\temp\[backup]_2024\final-version (2).bak" & @CRLF & _ "assets\images\new.logo-2025_v2\icon@2x#1.png" & @CRLF & _ "..\users\Jay Soren\Documents (Archived)\plan[final].docx" & @CRLF & _ "projects\#active-clients\ACME_Corp\Q2 Report\summary v1.3.pdf" & @CRLF & _ "config\env-settings\!urgent.env" & @CRLF & _ "media\🎵 music\lo-fi & chill\set_03 (remastered).wav" & @CRLF & _ "..\..\data\[raw]_input_🧪\test-sample(01).csv" & @CRLF & _ "src\core.modules\engine@v4.2.1.dll" & @CRLF & _ "docs\2025_06\meeting_notes (draft)\📝summary_notes.md" & @CRLF & _ "themes\🌑 darkmode (beta)\style-final!.css" & @CRLF & _ "..\..\logs\🪵 log-archive\2023-12-25 [Christmas].log" & @CRLF & _ "downloads\zips\patch_update v3.4-final!.zip" & @CRLF & _ "build\#output$\v2.1.1\installer(64bit).exe" & @CRLF & _ "components\UI-Toolkit_🔥\modal.dialog.js" & @CRLF & _ "scripts\batch jobs\cleanup-temp_files!.bat" & @CRLF & _ "resources\📁 static\fonts\Roboto_Bold-Italic.ttf" & @CRLF & _ "tests\[integration]_suite#2\test-case(01).spec.js" & @CRLF & _ "temp\$$merge_conflict\attempt_#3\resolved✅.txt" & @CRLF & _ "locales\en-US\messages(v1.0.0).json" & @CRLF & _ "backup\[legacy]_configs\1999.version.ini" & @CRLF & _ "src\modules\@internal\storage-handler.ts" & @CRLF & _ "..\releases\build#2025.06.14\installer-vFinal.exe" & @CRLF & _ "app\#dev[tools]\init.env.local" & @CRLF & _ "templates\html\base.template[mobile] v2.3.html" & @CRLF & _ "tools\@scripts\🧰_toolbelt\init+config.ps1" & @CRLF & _ "test_data\unit_tests\input(1)_#valid.json" & @CRLF & _ "uploads\archive\⚠️_caution\delete_me_later!.txt" & @CRLF & _ "plugins\[effects]_pack_v2.0\shine++.aex" & @CRLF & _ "scripts\build-process\generate_docs.sh" & @CRLF & _ "media\[video]_exports\final-cut[HD] 2025-06.mp4" & @CRLF & _ "src\experimental\feat_XYZ\🤖 robot_model_v7.py" & @CRLF & _ "themes\🖼️_gallery-view\art_styles(alt).css" & @CRLF & _ "..\..\app\modules@deprecated\beta_handler_old.py" & @CRLF & _ "lib\_core_\v5.5.0-preview\main-module.dll" & @CRLF & _ "config\!config\alt-🧬variant(2024).cfg" & @CRLF & _ "resources\svg\📦 package_icons\box-outline#new.svg" & @CRLF & _ "env\.private\__secrets__\[do_not_share].key" & @CRLF & _ "db\migrations\version_003(rollback).sql" & @CRLF & _ "projects\🔥_hotfix-2025.06.01\readme[fixed].md" & @CRLF & _ "user\@jay-s\📂work-in-progress\demo_v0.1(🛠️).pptx" & @CRLF & _ "docs\[TOC]_index\ch-02#advanced-topics.md" & @CRLF & _ "downloads\[temp]_🧼cleanup_dir\file 001.tmp" & @CRLF & _ "scripts\dev\postinstall_hooks\hook-runner!.ps1" & @CRLF & _ "logs\📊_analytics\[monthly]_stats-06-2025.csv" & @CRLF & _ "tests\[🔥stress]_loadtest-v99-final_(PASS).log" & @CRLF & _ "source\hidden\.config_dir\!local.env" & @CRLF & _ "tasks\[🧾]_todo_list (critical).txt" & @CRLF & _ "patches\archive\ver_1.0.0-beta2#RC1.zip" & @CRLF & _ "themes\theme_pack-v9.9\[ocean🌊]\index.theme" & @CRLF & _ "assets\icons_special\svg[✔️].iconset\✅checked.svg" & @CRLF & _ "utils\run$now\📈metrics-collector.ts" & @CRLF & _ "notes\[📚]_reference_materials (v3).pdf" & @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