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
  • Match everything enclosed
    (?:...)
  • Capture everything enclosed
    (...)
  • 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)^(\|-uint32_t \(\[\d*\]\) \= (\d*) \(\dx\w+\))" Local $sString = "|-uint32_t ([0]) = 2865385407 (0xaaca4fbf)" & @CRLF & _ "|-uint32_t ([1]) = 2865397407 (0xaaca7e9f)" & @CRLF & _ "|-uint32_t ([2]) = 2865409407 (0xaacaad7f)" & @CRLF & _ "|-uint32_t ([3]) = 2865421407 (0xaacadc5f)" & @CRLF & _ "|-uint32_t ([4]) = 2865433407 (0xaacb0b3f)" & @CRLF & _ "|-uint32_t ([5]) = 2865445407 (0xaacb3a1f)" & @CRLF & _ "|-uint32_t ([6]) = 2865457407 (0xaacb68ff)" & @CRLF & _ "|-uint32_t ([7]) = 2865469407 (0xaacb97df)" & @CRLF & _ "|-uint32_t ([8]) = 2865481407 (0xaacbc6bf)" & @CRLF & _ "|-uint32_t ([9]) = 2865493407 (0xaacbf59f)" & @CRLF & _ "|-uint32_t ([10]) = 2865505407 (0xaacc247f)" & @CRLF & _ "|-uint32_t ([11]) = 2865517407 (0xaacc535f)" & @CRLF & _ "|-uint32_t ([12]) = 2865529407 (0xaacc823f)" & @CRLF & _ "|-uint32_t ([13]) = 2865541408 (0xaaccb120)" & @CRLF & _ "|-uint32_t ([14]) = 2865553408 (0xaacce000)" & @CRLF & _ "|-uint32_t ([15]) = 2865565408 (0xaacd0ee0)" & @CRLF & _ "|-uint32_t ([16]) = 2865577408 (0xaacd3dc0)" & @CRLF & _ "|-uint32_t ([17]) = 2865589408 (0xaacd6ca0)" & @CRLF & _ "|-uint32_t ([18]) = 2865601408 (0xaacd9b80)" & @CRLF & _ "|-uint32_t ([19]) = 2865613408 (0xaacdca60)" & @CRLF & _ "|-uint32_t ([20]) = 2865625408 (0xaacdf940)" & @CRLF & _ "|-uint32_t ([21]) = 2865637408 (0xaace2820)" & @CRLF & _ "|-uint32_t ([22]) = 2865649408 (0xaace5700)" & @CRLF & _ "|-uint32_t ([23]) = 2865661408 (0xaace85e0)" & @CRLF & _ "|-uint32_t ([24]) = 2865673408 (0xaaceb4c0)" & @CRLF & _ "|-uint32_t ([25]) = 2865685408 (0xaacee3a0)" & @CRLF & _ "|-uint32_t ([26]) = 2865697408 (0xaacf1280)" & @CRLF & _ "|-uint32_t ([27]) = 2865709408 (0xaacf4160)" & @CRLF & _ "|-uint32_t ([28]) = 2865721408 (0xaacf7040)" & @CRLF & _ "|-uint32_t ([29]) = 2865733409 (0xaacf9f21)" & @CRLF & _ "|-uint32_t ([30]) = 2865745409 (0xaacfce01)" & @CRLF & _ "|-uint32_t ([31]) = 2865757409 (0xaacffce1)" & @CRLF & _ "|-uint32_t ([32]) = 2865769409 (0xaad02bc1)" & @CRLF & _ "|-uint32_t ([33]) = 2865781409 (0xaad05aa1)" & @CRLF & _ "|-uint32_t ([34]) = 2865793409 (0xaad08981)" & @CRLF & _ "|-uint32_t ([35]) = 2865805409 (0xaad0b861)" & @CRLF & _ "|-uint32_t ([36]) = 2865817409 (0xaad0e741)" & @CRLF & _ "|-uint32_t ([37]) = 2865829409 (0xaad11621)" & @CRLF & _ "|-uint32_t ([38]) = 2865841409 (0xaad14501)" & @CRLF & _ "|-uint32_t ([39]) = 2865853409 (0xaad173e1)" & @CRLF & _ "" Local $sSubst = "\2" 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