Regular Expressions 101

Save & Manage Regex

  • Current Version: 1
  • Save & Share
  • Community Library

Flavor

  • PCRE2 (PHP)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java
  • .NET 7.0 (C#)
  • Rust
  • PCRE (Legacy)
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests
Sponsors
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
Processing...

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)(\$)([^$]+)(\$)" Local $sString = "\documentclass{article}" & @CRLF & _ "%\usepackage[T1]{fontenc}" & @CRLF & _ "%\usepackage{textcomp}" & @CRLF & _ "%\usepackage[math]{iwona}" & @CRLF & _ "\usepackage[lf,minionint]{MinionPro}" & @CRLF & _ "\usepackage{a4,bm}" & @CRLF & _ "%\usepackage{dotlessj}" & @CRLF & _ "\pagestyle{empty}" & @CRLF & _ "\begin{document}" & @CRLF & _ "\begin{center}" & @CRLF & _ "{\Large{\bfseries Test of the font {\scshape MinionPro}.}}\bigskip\\" & @CRLF & _ "{\Large\verb|\usepackage[lf,minionint]{MinionPro}|}" & @CRLF & _ "%\medskip\\" & @CRLF & _ "%{\verb|\usepackage[romanfamily=bright-osf]{lucimatx}|} if you want old-style figures (like this: \oldstylenums{1695})\\" & @CRLF & _ "\end{center}" & @CRLF & _ "" & @CRLF & _ "The default math mode font is $Math\ Italic$. This should not be" & @CRLF & _ "confused with ordinary \emph{Text Italic} -- notice the different spacing\,!" & @CRLF & _ "\verb|\mathbf| produces bold roman letters: $ \mathbf{abcABC} $." & @CRLF & _ "If you wish to embolden complete formulas," & @CRLF & _ "use the \verb|\boldmath| command \emph{before} going into math mode. " & @CRLF & _ "This changes the default math fonts to bold. " & @CRLF & _ " " & @CRLF & _ "\begin{tabular}{ll}" & @CRLF & _ "\texttt{normal} & $ x = 2\pi \Rightarrow x \simeq 6.28 $\\" & @CRLF & _ "\texttt{mathbf} & $\mathbf{x} = 2\pi \Rightarrow \mathbf{x} \simeq 6.28 $\\" & @CRLF & _ "\texttt{boldmath} & {\boldmath $x = \mathbf{2}\pi \Rightarrow x " & @CRLF & _ " \simeq{\mathbf{6.28}} $}\\" & @CRLF & _ "\end{tabular}" & @CRLF & _ "\smallskip" & @CRLF & _ "" & @CRLF & _ "Greek is available in upper and lower case:" & @CRLF & _ "$\alpha,\beta \dots \Omega$, and there are special" & @CRLF & _ "symbols such as $ \hbar$." & @CRLF & _ "%The following letters should be upright: $\upGamma, \upDelta\dots \upOmega$." & @CRLF & _ "Digits in formulas $1, 2, 3\dots$ may differ from those in text: 1, 2, 3\dots" & @CRLF & _ "" & @CRLF & _ "There is a calligraphic alphabet \verb|\mathcal| for upper case letters" & @CRLF & _ "$ \mathcal{ABCDE}\dots $." & @CRLF & _ "%and there are letters for number sets: $\mathbb{A\dots Z} $, which are produced using \verb|\mathbb|." & @CRLF & _ "" & @CRLF & _ "\noindent" & @CRLF & _ "This font has both lining figures (13589, default) and oldstyle figures (\oldstylenums{13589}, select with {\tt$\backslash$oldstylenums\{..\}}). " & @CRLF & _ "%{\em \swshape{I}t \swshape{A}lso \swshape{H}as \swshape{S}wash \swshape{I}talics} {\tt$\backslash$swshape\{..\}}" & @CRLF & _ "\\" & @CRLF & _ "{\fontseries{c}\selectfont there is also a condensed weight} {\tt$\backslash$fontseries\{c\}$\backslash$selectfont}" & @CRLF & _ " " & @CRLF & _ "\begin{equation}" & @CRLF & _ " \phi(t)=\frac{1}{\sqrt{2\pi}}" & @CRLF & _ " \int^t_0 e^{-x^2/2} dx " & @CRLF & _ "\end{equation}" & @CRLF & _ "" & @CRLF & _ "\begin{equation}" & @CRLF & _ " \prod_{j\geq 0}" & @CRLF & _ " \left(\sum_{k\geq 0}a_{jk} z^k\right) " & @CRLF & _ "= \sum_{k\geq 0} z^n" & @CRLF & _ " \left( \sum_{{k_0,k_1,\ldots\geq 0}" & @CRLF & _ " \atop{k_0+k_1+\ldots=n} }" & @CRLF & _ " a{_0k_0}a_{1k_1}\ldots \right) " & @CRLF & _ "\end{equation}" & @CRLF & _ "" & @CRLF & _ "\begin{equation}" & @CRLF & _ "\pi(n) = \sum_{m=2}^{n}" & @CRLF & _ " \left\lfloor \left(\sum_{k=1}^{m-1}" & @CRLF & _ " \lfloor(m/k)/\lceil m/k\rceil " & @CRLF & _ " \rfloor \right)^{-1}" & @CRLF & _ " \right\rfloor" & @CRLF & _ "\end{equation}" & @CRLF & _ "" & @CRLF & _ "\begin{equation}" & @CRLF & _ "\{\underbrace{%" & @CRLF & _ " \overbrace{\mathstrut a,\ldots,a}^{k\ a's}," & @CRLF & _ " \overbrace{\mathstrut b,\ldots,b}^{l\ b's}}" & @CRLF & _ " _{k+1\ \mathrm{elements}} \}" & @CRLF & _ "\end{equation}" & @CRLF & _ "" & @CRLF & _ "\begin{displaymath}" & @CRLF & _ "\mbox{W}^+\" & @CRLF & _ "\begin{array}{l}" & @CRLF & _ "\nearrow\raise5pt\hbox{$\mu^+ + \nu_{\mu}$}\\" & @CRLF & _ "\rightarrow \pi^+ +\pi^0 \\[5pt]" & @CRLF & _ "\rightarrow \kappa^+ +\pi^0 \\" & @CRLF & _ "\searrow\lower5pt\hbox{$\mathrm{e}^+ " & @CRLF & _ " +\nu_{\scriptstyle\mathrm{e}}$}" & @CRLF & _ "\end{array}" & @CRLF & _ "\end{displaymath}" & @CRLF & _ "" & @CRLF & _ "\begin{displaymath}" & @CRLF & _ "\frac{\pm" & @CRLF & _ "\left|\begin{array}{ccc}" & @CRLF & _ "x_1-x_2 & y_1-y_2 & z_1-z_2 \\" & @CRLF & _ "l_1 & m_1 & n_1 \\" & @CRLF & _ "l_2 & m_2 & n_2" & @CRLF & _ "\end{array}\right|}{" & @CRLF & _ "\sqrt{\left|\begin{array}{cc}l_1&m_1\\" & @CRLF & _ "l_2&m_2\end{array}\right|^2" & @CRLF & _ "+ \left|\begin{array}{cc}m_1&n_1\\" & @CRLF & _ "n_1&l_1\end{array}\right|^2" & @CRLF & _ "+ \left|\begin{array}{cc}m_2&n_2\\" & @CRLF & _ "n_2&l_2\end{array}\right|^2}}" & @CRLF & _ "\end{displaymath}" & @CRLF & _ "" & @CRLF & _ "text accents: \`{a},\'{a},\"{a},\^{a}" & @CRLF & _ "may differ from math accents:" & @CRLF & _ "\begin{displaymath}" & @CRLF & _ "\mbox{ acute=}\acute{a}" & @CRLF & _ "\mbox{ grave=}\grave{a}" & @CRLF & _ "\mbox{ ddot=}\ddot {a}" & @CRLF & _ "\mbox{ tilde=}\tilde{a}" & @CRLF & _ "\mbox{ bar=}\bar {a}" & @CRLF & _ "\mbox{ breve=}\breve{a}" & @CRLF & _ "\mbox{ check=}\check{a}" & @CRLF & _ "\mbox{ hat=}\hat {a}" & @CRLF & _ "\mbox{ vec=}\vec {a}" & @CRLF & _ "\mbox{ dot=}\dot {a}" & @CRLF & _ "\end{displaymath}" & @CRLF & _ "" & @CRLF & _ "dotlessi=\i\ " & @CRLF & _ "dotlessj=\j\ " & @CRLF & _ "dagger=$\dagger$\ \ \ " & @CRLF & _ "\verb|\bm{x}|\ $\bm{x}$ " & @CRLF & _ "" & @CRLF & _ "%$\hbar$ $\hslash$" & @CRLF & _ "\end{document}" & @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