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

Substitution

Processing...

Code Generator

Generated Code

#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox Local $sRegex = "(?m)^((.+)\.TP.+\.LS\t)(.{2,99})$" Local $sString = "BG_LOGIC.TP BG_LOGIC.LS BG Logic" & @CRLF & _ "CICLO.TP CICLO.LS Ciclo carico" & @CRLF & _ "CICLO_SIM.TP CICLO_SIM.LS Ciclo carico" & @CRLF & _ "CLSKP_G1.TP CLSKP_G1.LS set skip cond g1" & @CRLF & _ "CLSKP_G2.TP CLSKP_G2.LS set skip cond g2" & @CRLF & _ "CLSKP_G3.TP CLSKP_G3.LS set skip cond g3" & @CRLF & _ "CLSKP_G4.TP CLSKP_G4.LS set skip cond g4" & @CRLF & _ "CLSKP_G5.TP CLSKP_G5.LS set skip cond g5" & @CRLF & _ "CLSKP_G6.TP CLSKP_G6.LS set skip cond g6" & @CRLF & _ "CLSKP_G7.TP CLSKP_G7.LS set skip cond g7" & @CRLF & _ "CLSKP_G8.TP CLSKP_G8.LS set skip cond g8" & @CRLF & _ "CMD_TOOL.TP CMD_TOOL.LS Comandi tool" & @CRLF & _ "CTRL_COLORE.TP CTRL_COLORE.LS Controllo colore" & @CRLF & _ "CTRL_SMUS.TP CTRL_SMUS.LS Controllo smussi" & @CRLF & _ "DEFINREG.TP DEFINREG.LS Defin. registri" & @CRLF & _ "DEFINTOO.TP DEFINTOO.LS Definisci tool" & @CRLF & _ "DEF_PR.TP DEF_PR.LS Defin. PR ciclo" & @CRLF & _ "DEF_PR_DEMO.TP DEF_PR_DEMO.LS Defin. PR ciclo" & @CRLF & _ "DEMO_CLC.TP DEMO_CLC.LS Cycle DEMO" & @CRLF & _ "DEMO_OFF.TP DEMO_OFF.LS Ciclo Demo Offst" & @CRLF & _ "DOFF_NTV.TP DOFF_NTV.LS DemoOffs no Tav" & @CRLF & _ "DOFF_TAV.TP DOFF_TAV.LS DemoOffs con Tav" & @CRLF & _ "GETDATA.TP GETDATA.LS Get PC Data" & @CRLF & _ "HOME.TP HOME.LS Vai a Home" & @CRLF & _ "HOMESCAR.TP HOMESCAR.LS Home+Scarto" & @CRLF & _ "INIT.TP INIT.LS InitVars" & @CRLF & _ "INIT_CICLO.TP INIT_CICLO.LS InitCiclo" & @CRLF & _ "INIT_POS.TP INIT_POS.LS InitPosizioni" & @CRLF & _ "LASCIA.TP LASCIA.LS Lascia pastiglia" & @CRLF & _ "MAGNETE1.TP MAGNETE1.LS Cmd magnete A" & @CRLF & _ "MAGNETE2.TP MAGNETE2.LS Cmd magnete B" & @CRLF & _ "MANUT.TP MANUT.LS Manutenzione" & @CRLF & _ "OFFSET.TP OFFSET.LS Offset da PLC" & @CRLF & _ "OVERRIDE.TP OVERRIDE.LS Assegna Override" & @CRLF & _ "OVER_BAS.TP OVER_BAS.LS Override ridotta" & @CRLF & _ "OVER_LIM.TP OVER_LIM.LS BG_Logic" & @CRLF & _ "OVER_RIP.TP OVER_RIP.LS BG_Logic" & @CRLF & _ "POSIZIONE.TP POSIZIONE.LS COMPARATORE" & @CRLF & _ "PREDISP_TAV.TP PREDISP_TAV.LS Piano formella" & @CRLF & _ "PRENDI.TP PRENDI.LS Prendi pastiglia" & @CRLF & _ "PRG_1.TP PRG_1.LS 1336" & @CRLF & _ "PRG_2.TP PRG_2.LS 549 Hole" & @CRLF & _ "PRG_3.TP PRG_3.LS 201659.100" & @CRLF & _ "PRG_998.TP PRG_998.LS NoHole" & @CRLF & _ "PRG_999.TP PRG_999.LS Hole" & @CRLF & _ "PRIOR_PREL.TP PRIOR_PREL.LS Prior. prelievo" & @CRLF & _ "PROVA.TP PROVA.LS Test" & @CRLF & _ "PULPZ.TP PULPZ.LS Pulizia pinza" & @CRLF & _ "REQMENU.TP REQMENU.LS Request PC Menu" & @CRLF & _ "RISCAL.TP RISCAL.LS Riscaldamento" & @CRLF & _ "RSR0001.TP RSR0001.LS Prog. Avvio" & @CRLF & _ "SCARTO.TP SCARTO.LS Scarto" & @CRLF & _ "SENDDATA.TP SENDDATA.LS Send PC Data" & @CRLF & _ "SENDEVNT.TP SENDEVNT.LS Send PC Event" & @CRLF & _ "SENDSYSV.TP SENDSYSV.LS Send PC SysVar" & @CRLF & _ "SETSKCOL.TP SETSKCOL.LS setskipcondition" & @CRLF & _ "SET_SR.TP SET_SR.LS Set string reg." & @CRLF & _ "TARA_COLORE.TP TARA_COLORE.LS Tara ctrl colore" & @CRLF & _ "TEST.TP TEST.LS Temp" & @CRLF & _ "TEST_MOV.TP TEST_MOV.LS Prova movimenti" & @CRLF & _ "VRFYPREL.TP VRFYPREL.LS Check Prel. Nas." & @CRLF & _ "VRFYPRTV.TP VRFYPRTV.LS Check Prel. Tav." & @CRLF & _ "_MAIN.TP _MAIN.LS Prog. principale" & @CRLF & _ "_RESET.TP _RESET.LS Carica punti" & @CRLF & _ "" Local $sSubst = "PRG\t\2\t\3" Local $sResult = StringRegExpReplace($sString, $sRegex, $sSubst) MsgBox($MB_SYSTEMMODAL, "Result", $sResult)

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