Regular Expressions 101

Save & Share

  • Regex Version: ver. 1
  • Fork Regex
    ctrl+s
  • Add to Community Library

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

/
/
gixu

Test String

Substitution

Processing...

Code Generator

Generated Code

#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox Local $sRegex = "(?ixu)# Definição de ordens" & @CRLF & _ "(?(DEFINE)(?P<unidades> um|dois|tr[eê]s|quatro|cinco|meia|se(?:is|te)|oito|nove ))" & @CRLF & _ "(?(DEFINE)(?P<dezenas_dez> d(?:ez(?:e(?:nove|sse(?:is|te))|oito)?|oze)|onze|treze|catorze|quinze ))" & @CRLF & _ "(?(DEFINE)(?P<dezenas_exceto_dez> vinte|trinta|(?:quar|cinqu|se(?:ss|t)|oit|nov)enta ))" & @CRLF & _ "(?(DEFINE)(?P<dezenas> (?P>dezenas_dez)|(?P>dezenas_exceto_dez) ))" & @CRLF & _ "(?(DEFINE)(?P<dezenas_ou_unidades> (?P>dezenas)|(?P>unidades) ))" & @CRLF & _ "(?(DEFINE)(?P<centenas> ce(?:m|ntos?)|(?:qu(?:atroc|inh)|(?:du|tre|se(?:is|te)|oito|nove)[cz])entos? ))" & @CRLF & _ "(?(DEFINE)(?P<mil> mil ))" & @CRLF & _ "(?(DEFINE)(?P<milhoes> (?:(?:[mb]|tr)i|qu(?:atri|inqua))lh(?:[aã]o|[oõ]es) ))" & @CRLF & _ "(?(DEFINE)(?P<s> [ ]+ ))" & @CRLF & _ "(?(DEFINE)(?P<e> e(?P>s) ))" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "#Regras" & @CRLF & _ "\b(?:" & @CRLF & _ "" & @CRLF & _ " #1. Entre dezenas>=20 e unidades" & @CRLF & _ " (?P>dezenas_exceto_dez)(?P>s)(?=(?P>unidades)\b)" & @CRLF & _ "|" & @CRLF & _ " #2. Entre centenas e dezenas ou unidades" & @CRLF & _ " (?P>centenas)(?P>s)(?=(?P>dezenas_ou_unidades)\b)" & @CRLF & _ "|" & @CRLF & _ " #3-4. Entre milhares..." & @CRLF & _ " (?P>mil)(?P>s)(?=" & @CRLF & _ " (?:" & @CRLF & _ " #3. ... e dezenas ou unidades" & @CRLF & _ " (?P>dezenas_ou_unidades)" & @CRLF & _ " |" & @CRLF & _ " #4. ... e centenas, somente se não houver dezenas ou unidades" & @CRLF & _ " (?P>centenas)(?!(?P>s)(?P>e)?(?P>dezenas_ou_unidades)\b)" & @CRLF & _ " )" & @CRLF & _ " \b" & @CRLF & _ " )" & @CRLF & _ "|" & @CRLF & _ " #5. Entre milhões e dezenas ou unidades (que não sejam unidades ou dezenas de milhões ou unidades ou dezenas de milhares)" & @CRLF & _ " (?P>milhoes)(?P>s)(?=" & @CRLF & _ " (?P>dezenas_ou_unidades)(?!(?P>s)(?P>e)?(?:(?P>unidades)(?P>s)(?P>e)?)?(?:(?P>milhoes)|(?P>mil))\b)\b" & @CRLF & _ " " & @CRLF & _ " )" & @CRLF & _ "" & @CRLF & _ ")" & @CRLF & _ "\b" & @CRLF & _ "" & @CRLF & _ "#Reset" & @CRLF & _ "\K" Local $sString = "vinte cinco" & @CRLF & _ "vinte cinco mil" & @CRLF & _ "vinte cinco reais" & @CRLF & _ "vinte cinco reais e vinte cinco centavos" & @CRLF & _ "aaa bbb ccc" & @CRLF & _ "dois mil trezentos" & @CRLF & _ "dois mil trezentos quarenta cinco" & @CRLF & _ "dois milhões trinta um" & @CRLF & _ "dois milhões trinta um mil" & @CRLF & _ "dois milhões trinta mil" & @CRLF & _ "cento vinte três milhões quatrocentos cinquenta seis mil setecentos oitenta nove" Local $sSubst = "e " 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