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)(\d{10})_([A-Z][a-z]+)([A-Z][a-z]+)(\.[a-zA-Z]{3,4})" Local $sString = "1173216167_AgentWill.jpg" & @CRLF & _ "1173216768_BrooksHarold.jpg" & @CRLF & _ "1173299189_BurgessDon.jpg" & @CRLF & _ "1173299407_ConiglioMike.jpg" & @CRLF & _ "1173299438_CooperKaren.jpg" & @CRLF & _ "1173299499_CurtisChristopher.jpg" & @CRLF & _ "1173300038_ElmoreKim.jpg" & @CRLF & _ "1173300155_FarmerVicki.jpg" & @CRLF & _ "1173300181_FletcherSteve.jpg" & @CRLF & _ "1173300207_ForrenEddie.jpg" & @CRLF & _ "1173300279_McguckinLinda.jpg" & @CRLF & _ "1173300440_GourleyJj.jpg" & @CRLF & _ "1173300567_HeinslemanPam.jpg" & @CRLF & _ "1173300593_HondlKurt.jpg" & @CRLF & _ "1173300619_HornJeff.jpg" & @CRLF & _ "1173300646_HowardKen.jpg" & @CRLF & _ "1173300716_IvicIgor.jpg" & @CRLF & _ "1173300757_JainMike.jpg" & @CRLF & _ "1173300862_KainJack.jpg" & @CRLF & _ "1173302066_KennedyDoug.jpg" & @CRLF & _ "1173302338_KuhlmanKristin.jpg" & @CRLF & _ "1173302528_LangstronCarrie.jpg" & @CRLF & _ "1173302580_LynnKelly.jpg" & @CRLF & _ "1173302631_MacgormanDon.jpg" & @CRLF & _ "1173303489_MelnikovValery.jpg" & @CRLF & _ "1173303530_MorrowBrett.jpg" & @CRLF & _ "1173303596_MurnanJames.jpg" & @CRLF & _ "1173303818_OrtegaKiel.jpg" & @CRLF & _ "1173304172_RabinBob.jpg" & @CRLF & _ "1173304254_RollinsTonia.jpg" & @CRLF & _ "1173304421_SchmidtMike.jpg" & @CRLF & _ "1173304508_SchurrTerry.jpg" & @CRLF & _ "1173304851_StumpfGreg.jpg" & @CRLF & _ "1173304935_TarpKeli.jpg" & @CRLF & _ "1173305069_ToomeyRobert.jpg" & @CRLF & _ "1173305102_TorresSebastian.jpg" & @CRLF & _ "1173305301_WickerLou.jpg" & @CRLF & _ "1173305326_WittArthur.jpg" & @CRLF & _ "1173305357_WoodBim.jpg" & @CRLF & _ "1173305420_XuQin.jpg" & @CRLF & _ "1173305550_YussoufNusrat.jpg" & @CRLF & _ "1173305582_ZahraiAllen.jpg" & @CRLF & _ "1173305608_ZhangPengfei.jpg" & @CRLF & _ "1173305634_ZhangJian.jpg" & @CRLF & _ "1173305666_ZieglerConrad.jpg" & @CRLF & _ "1173305696_ZrnicDusan.jpg" & @CRLF & _ "1178031443_LewisJohn.jpg" & @CRLF & _ "1208811784_DoviakRichard.jpg" & @CRLF & _ "1208811993_KrauseJohn.jpg" & @CRLF & _ "1208812047_MansellTed.jpg" & @CRLF & _ "1208812483_PepplerRandy.jpg" & @CRLF & _ "1208812511_ReevesHeather.jpg" & @CRLF & _ "1208812542_RobertsBrett.jpg" & @CRLF & _ "1208812597_WaughSean.jpg" & @CRLF & _ "1248986831_Warde-David.jpg" & @CRLF & _ "1248987295_Smith--Travis.jpg" & @CRLF & _ "1248987685_Knopfmeier--Kent.jpg" & @CRLF & _ "1248987721_GRIFFIN-ERICA.jpg" & @CRLF & _ "1248987828_Brogden--Jeff.jpg" & @CRLF & _ "1248987872_Arthur-Ami.jpg" & @CRLF & _ "1249399247_Nemunaitis-Kodi.jpg" & @CRLF & _ "1258400095_Clark-Adam.jpg" & @CRLF & _ "1258400182_Stratman-Derek.jpg" & @CRLF & _ "1258755192_Schwarz--Chris.jpg" & @CRLF & _ "1271793238_humberto.jpg" & @CRLF & _ "1273024015_BrianKaney2003.jpg" & @CRLF & _ "1278003921_Butler-Sterling.jpg" & @CRLF & _ "1278004017_Reinke-Tracy.jpg" & @CRLF & _ "1278004036_Ryzhkov-Alexander.jpg" & @CRLF & _ "1278004055_Tang-Lin.jpg" & @CRLF & _ "1278004074_Wang-Yadong.jpg" & @CRLF & _ "1297362249_Jones-Thomas.jpg" & @CRLF & _ "1297362283_Potvin-Corey.jpg" & @CRLF & _ "1311024411_Crank-Linda.jpg" & @CRLF & _ "1311024437_Gao-Jidong.jpg" & @CRLF & _ "1311024633_Smith-Brandon.jpg" & @CRLF & _ "1391808396_Bowden-Katie.jpg" & @CRLF & _ "1401375264_Meitin_jose.jpg" & @CRLF & _ "1407171270_Carlin_Jacob.jpg" & @CRLF & _ "1407171306_Cocks_Stephen.jpg" & @CRLF & _ "1407171371_Creager_Gerald.jpg" & @CRLF & _ "1407171682_Kirstetter-Pierre.jpg" & @CRLF & _ "1407171749_Kuster_Charles.jpg" & @CRLF & _ "1407171773_Martinaitis_Steven.jpg" & @CRLF & _ "1407171792_Mirkovic_Djordje.jpg" & @CRLF & _ "1407171905_Shattuck_Micheal.jpg" & @CRLF & _ "1407171947_Snyder_Jeffrey.jpg" & @CRLF & _ "1407172034_Wadler_Joshua.jpg" & @CRLF & _ "1418052845_D-Wasielewski.jpg" 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