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

/
/
i

Test String

Substitution

Processing...

Code Generator

Generated Code

#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox Local $sRegex = "(?i)\s+TStatusBar" Local $sString = "inherited FormPadrao: TFormPadrao" & @CRLF & _ " Left = 354" & @CRLF & _ " Top = 155" & @CRLF & _ " Caption = 'FormPadrao'" & @CRLF & _ " ClientHeight = 342" & @CRLF & _ " ClientWidth = 655" & @CRLF & _ " KeyPreview = True" & @CRLF & _ " PopupMenu = MnPop_Principal" & @CRLF & _ " OnCloseQuery = FormCloseQuery" & @CRLF & _ " OnDeactivate = FormDeactivate" & @CRLF & _ " ExplicitWidth = 671" & @CRLF & _ " ExplicitHeight = 381" & @CRLF & _ " DesignSize = (" & @CRLF & _ " 655" & @CRLF & _ " 342)" & @CRLF & _ " PixelsPerInch = 96" & @CRLF & _ " TextHeight = 15" & @CRLF & _ " object Bv_Top: TBevel [0]" & @CRLF & _ " Left = 0" & @CRLF & _ " Top = 0" & @CRLF & _ " Width = 655" & @CRLF & _ " Height = 2" & @CRLF & _ " Align = alTop" & @CRLF & _ " end" & @CRLF & _ " object Sb_FormPadrao: TStatusBar [1]" & @CRLF & _ " Left = 0" & @CRLF & _ " Top = 317" & @CRLF & _ " Width = 655" & @CRLF & _ " Height = 25" & @CRLF & _ " Panels = <" & @CRLF & _ " item" & @CRLF & _ " Bevel = pbNone" & @CRLF & _ " Text = 'Usu'#225'rio'" & @CRLF & _ " Width = 100" & @CRLF & _ " end" & @CRLF & _ " item" & @CRLF & _ " Bevel = pbNone" & @CRLF & _ " Width = 50" & @CRLF & _ " end>" & @CRLF & _ " ParentColor = True" & @CRLF & _ " ParentFont = True" & @CRLF & _ " UseSystemFont = False" & @CRLF & _ " ExplicitTop = 323" & @CRLF & _ " end" & @CRLF & _ " object Pn_BaseToolBar: TPanel [2]" & @CRLF & _ " Left = 0" & @CRLF & _ " Top = 2" & @CRLF & _ " Width = 655" & @CRLF & _ " Height = 73" & @CRLF & _ " Align = alTop" & @CRLF & _ " BevelOuter = bvNone" & @CRLF & _ " ParentColor = True" & @CRLF & _ " TabOrder = 2" & @CRLF & _ " end" & @CRLF & _ " object Pn_BaseGrid: TPanel [3]" & @CRLF & _ " Left = 0" & @CRLF & _ " Top = 75" & @CRLF & _ " Width = 655" & @CRLF & _ " Height = 242" & @CRLF & _ " Align = alClient" & @CRLF & _ " BevelOuter = bvNone" & @CRLF & _ " BorderWidth = 3" & @CRLF & _ " ParentColor = True" & @CRLF & _ " TabOrder = 4" & @CRLF & _ " ExplicitLeft = 32" & @CRLF & _ " ExplicitTop = 95" & @CRLF & _ " ExplicitHeight = 222" & @CRLF & _ " end" & @CRLF & _ " inherited MinMax: TmgMinMax" & @CRLF & _ " Top = 7" & @CRLF & _ " MinTrackSize.X = 450" & @CRLF & _ " MinTrackSize.Y = 300" & @CRLF & _ " ExplicitTop = 7" & @CRLF & _ " end" & @CRLF & _ " object Mn_Principal: TMainMenu [6]" & @CRLF & _ " Left = 4" & @CRLF & _ " Top = 36" & @CRLF & _ " object miTabela: TMenuItem" & @CRLF & _ " Caption = '&Tabela'" & @CRLF & _ " object miInserir: TMenuItem" & @CRLF & _ " Caption = '&Inserir'" & @CRLF & _ " end" & @CRLF & _ " object miApagar: TMenuItem" & @CRLF & _ " Caption = '&Apagar'" & @CRLF & _ " end" & @CRLF & _ " object miPropriedades: TMenuItem" & @CRLF & _ " Caption = '&Editar'" & @CRLF & _ " end" & @CRLF & _ " object N4: TMenuItem" & @CRLF & _ " Caption = '-'" & @CRLF & _ " end" & @CRLF & _ " object miFechar: TMenuItem" & @CRLF & _ " Caption = '&Fechar'" & @CRLF & _ " OnClick = miFecharClick" & @CRLF & _ " end" & @CRLF & _ " end" & @CRLF & _ " object miEditar1: TMenuItem" & @CRLF & _ " Caption = '&Editar'" & @CRLF & _ " object miRecortar1: TMenuItem" & @CRLF & _ " Caption = '&Recortar'" & @CRLF & _ " end" & @CRLF & _ " object miCopiar1: TMenuItem" & @CRLF & _ " Caption = '&Copiar'" & @CRLF & _ " end" & @CRLF & _ " object miColar1: TMenuItem" & @CRLF & _ " Caption = '&Colar'" & @CRLF & _ " end" & @CRLF & _ " end" & @CRLF & _ " object miExibir: TMenuItem" & @CRLF & _ " Caption = '&Exibir'" & @CRLF & _ " object miBarradeFerramentas: TMenuItem" & @CRLF & _ " Caption = 'Barra de &Ferramentas'" & @CRLF & _ " object miNaoExibir: TMenuItem" & @CRLF & _ " Caption = '&N'#227'o Exibir'" & @CRLF & _ " GroupIndex = 1" & @CRLF & _ " RadioItem = True" & @CRLF & _ " OnClick = mi_NaoExibirClick" & @CRLF & _ " end" & @CRLF & _ " object N5: TMenuItem" & @CRLF & _ " Caption = '-'" & @CRLF & _ " GroupIndex = 1" & @CRLF & _ " RadioItem = True" & @CRLF & _ " end" & @CRLF & _ " object miAlto: TMenuItem" & @CRLF & _ " Caption = '&Alto'" & @CRLF & _ " GroupIndex = 1" & @CRLF & _ " RadioItem = True" & @CRLF & _ " OnClick = mi_AltoClick" & @CRLF & _ " end" & @CRLF & _ " object miBaixo: TMenuItem" & @CRLF & _ " Caption = '&Baixo'" & @CRLF & _ " GroupIndex = 1" & @CRLF & _ " RadioItem = True" & @CRLF & _ " OnClick = mi_BaixoClick" & @CRLF & _ " end" & @CRLF & _ " end" & @CRLF & _ " object miBarradeStatus: TMenuItem" & @CRLF & _ " Caption = 'Barra de &Status'" & @CRLF & _ " OnClick = mi_BarradeStatusClick" & @CRLF & _ " end" & @CRLF & _ " object mi_SepN3: TMenuItem" & @CRLF & _ " Caption = '-'" & @CRLF & _ " end" & @CRLF & _ " object mi_Informacoesdajanela1: TMenuItem" & @CRLF & _ " Caption = 'Informa'#231#245'es desta Janela'" & @CRLF & _ " OnClick = mi_Informacoesdajanela1Click" & @CRLF & _ " end" & @CRLF & _ " object mi_Sepm9: TMenuItem" & @CRLF & _ " Caption = '-'" & @CRLF & _ " Visible = False" & @CRLF & _ " end" & @CRLF & _ " object mi_OcorrenciaAuditoria: TMenuItem" & @CRLF & _ " Caption = 'Logs de Auditoria'" & @CRLF & _ " Visible = False" & @CRLF & _ " OnClick = mi_OcorrenciaAuditoriaClick" & @CRLF & _ " end" & @CRLF & _ " end" & @CRLF & _ " object Mi_Ajuda: TMenuItem" & @CRLF & _ " Caption = '&Ajuda'" & @CRLF & _ " object Mi_AjudaProcesso: TMenuItem" & @CRLF & _ " Caption = 'Ajuda &Processo'" & @CRLF & _ " ShortCut = 112" & @CRLF & _ " OnClick = Mi_AjudaProcessoClick" & @CRLF & _ " end" & @CRLF & _ " object Mi_AjudaTela: TMenuItem" & @CRLF & _ " Caption = 'Ajuda &Tela'" & @CRLF & _ " ShortCut = 16496" & @CRLF & _ " OnClick = Mi_AjudaTelaClick" & @CRLF & _ " end" & @CRLF & _ " object Mi_HistoricoAlteracoes: TMenuItem" & @CRLF & _ " Caption = '&Hist'#243'rico de altera'#231#245'es'" & @CRLF & _ " Visible = False" & @CRLF & _ " OnClick = Mi_HistoricoAlteracoesClick" & @CRLF & _ " end" & @CRLF & _ " end" & @CRLF & _ " end" & @CRLF & _ " inherited mgPopupImpressao: TmgPopupMenu" & @CRLF & _ " Left = 4" & @CRLF & _ " end" & @CRLF & _ " object MnPop_Principal: TPopupMenu" & @CRLF & _ " Left = 34" & @CRLF & _ " Top = 36" & @CRLF & _ " object mi_Inserir: TMenuItem" & @CRLF & _ " Caption = '&Inserir'" & @CRLF & _ " end" & @CRLF & _ " object mi_Apagar: TMenuItem" & @CRLF & _ " Caption = '&Apagar'" & @CRLF & _ " end" & @CRLF & _ " object mi_Editar: TMenuItem" & @CRLF & _ " Caption = '&Editar'" & @CRLF & _ " end" & @CRLF & _ " object N1: TMenuItem" & @CRLF & _ " Caption = '-'" & @CRLF & _ " end" & @CRLF & _ " object mi_BarradeFerramentas: TMenuItem" & @CRLF & _ " Caption = '&Barra de Ferramentas'" & @CRLF & _ " object mi_NaoExibir: TMenuItem" & @CRLF & _ " Caption = '&N'#227'o Exibir'" & @CRLF & _ " GroupIndex = 1" & @CRLF & _ " RadioItem = True" & @CRLF & _ " OnClick = mi_NaoExibirClick" & @CRLF & _ " end" & @CRLF & _ " object N2: TMenuItem" & @CRLF & _ " Caption = '-'" & @CRLF & _ " GroupIndex = 1" & @CRLF & _ " RadioItem = True" & @CRLF & _ " end" & @CRLF & _ " object mi_Alto: TMenuItem" & @CRLF & _ " Caption = '&Alto'" & @CRLF & _ " GroupIndex = 1" & @CRLF & _ " RadioItem = True" & @CRLF & _ " OnClick = mi_AltoClick" & @CRLF & _ " end" & @CRLF & _ " object mi_Baixo: TMenuItem" & @CRLF & _ " Caption = '&Baixo'" & @CRLF & _ " GroupIndex = 1" & @CRLF & _ " RadioItem = True" & @CRLF & _ " OnClick = mi_BaixoClick" & @CRLF & _ " end" & @CRLF & _ " end" & @CRLF & _ " object mi_BarradeStatus: TMenuItem" & @CRLF & _ " Caption = 'Ba&rra de Status'" & @CRLF & _ " OnClick = mi_BarradeStatusClick" & @CRLF & _ " end" & @CRLF & _ " end" & @CRLF & _ "end" Local $sSubst = " TMgStatusBar" 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