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 single character of: a, b, c or d
    [[ab][cd]]
  • 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]
  • Character class intersection
    [\w&&[^\d]]
  • 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
No Match

"
"
gmi

Test String

Substitution

Processing...

Code Generator

Generated Code

#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox Local $sRegex = "(?mi).(?=.{4})" Local $sString = "usdfiusdgfisdgf" & @CRLF & _ "LovePizza" & @CRLF & _ "12,34,56,78" & @CRLF & _ "12.34.56,78" & @CRLF & _ "Esto es una prueba" & @CRLF & _ "hola" & @CRLF & _ "12345678" & @CRLF & _ "45345345343" & @CRLF & _ "Nananananananananananananananana Batman!" & @CRLF & _ "nada@gmail.com" & @CRLF & _ "lorena.loba@loquesea.gov.co" & @CRLF & _ "hola_3@gmail.com" & @CRLF & _ "adios@gmail.com" & @CRLF & _ "pruebagmail.com" & @CRLF & _ "pepe.trueno " & @CRLF & _ "patricia99.rica@.hotmail.com" & @CRLF & _ "lorena22.regalada" & @CRLF & _ "comercio.enproceso" & @CRLF & _ "daniela regalo" & @CRLF & _ "" & @CRLF & _ "gmail.com" & @CRLF & _ "redluis.luis@gmail.com" & @CRLF & _ "pepe_redluis@gmail.com" & @CRLF & _ "pepe_redluis@gmail.com" & @CRLF & _ "mart-red+luis@gmail.com.ve" & @CRLF & _ "" & @CRLF & _ "{" & @CRLF & _ ""servicio":"eval"," & @CRLF & _ ""eval":{" & @CRLF & _ ""10441":"valor.%substr%( 2, 2 )"," & @CRLF & _ ""10442":"valor"," & @CRLF & _ ""10443":"%mask%(valor,3)"" & @CRLF & _ "}," & @CRLF & _ ""operacion":"valor.%concat%(10442,10443,10441)"," & @CRLF & _ ""resultado":12022" & @CRLF & _ "}" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "1. Luciana: 4.216 " & @CRLF & _ "2. Isabella: 3.505 " & @CRLF & _ "3. Salomé: 2.829" & @CRLF & _ "4. Emmanuel: 2.688" & @CRLF & _ "5. Antonella: 2.643" & @CRLF & _ "6. Emiliano: 2454" & @CRLF & _ "7. Santiago: 2.383" & @CRLF & _ "8. Samuel: 2.256" & @CRLF & _ "9. Jerónimo: 2.167" & @CRLF & _ "10. Mariana: 2.160" & @CRLF & _ "" & @CRLF & _ "date,home_team,away_team,home_score,away_score,tournament,city,country,neutral" & @CRLF & _ "1872-11-30,Scotland,England,0,0,Friendly,Glasgow,Scotland,FALSE" & @CRLF & _ "1873-03-08,England,Scotland,4,2,Friendly,London,England,FALSE" & @CRLF & _ "1874-03-07,Scotland,England,2,1,Friendly,Glasgow,Scotland,FALSE" & @CRLF & _ "1875-03-06,England,Scotland,2,2,Friendly,London,England,FALSE" & @CRLF & _ "1876-03-04,Scotland,England,3,0,Friendly,Glasgow,Scotland,FALSE" & @CRLF & _ "1876-03-25,Scotland,Wales,4,0,Friendly,Glasgow,Scotland,FALSE" & @CRLF & _ "" & @CRLF & _ "1::Toy Story (1995)::Adventure|Animation|Children|Comedy|Fantasy" & @CRLF & _ "2::Jumanji (1995)::Adventure|Children|Fantasy" & @CRLF & _ "3::Grumpier Old Men (1995)::Comedy|Romance" & @CRLF & _ "4::Waiting to Exhale (1995)::Comedy|Drama|Romance" & @CRLF & _ "5::Father of the Bride Part II (1995)::Comedy" & @CRLF & _ "6::Heat (1995)::Action|Crime|Thriller" & @CRLF & _ "7::Sabrina (1995)::Comedy|Romance" & @CRLF & _ "8::Tom and Huck (1995)::Adventure|Children" & @CRLF & _ "9::Sudden Death (1995)::Action" & @CRLF & _ "10::GoldenEye (1995)::Action|Adventure|Thriller" & @CRLF & _ "11::American President, The (1995)::Comedy|Drama|Romance" & @CRLF & _ "12::Dracula: Dead and Loving It (1995)::Comedy|Horror" & @CRLF & _ "13::Balto (1995)::Animation|Children" & @CRLF & _ "14::Nixon (1995)::Drama" & @CRLF & _ "15::Cutthroat Island (1995)::Action|Adventure|Romance" & @CRLF & _ "16::Casino (1995)::Crime|Drama" & @CRLF & _ "17::Sense and Sensibility (1995)::Comedy|Drama|Romance" & @CRLF & _ "18::Four Rooms (1995)::Comedy|Drama|Thriller" & @CRLF & _ "19::Ace Ventura: When Nature Calls (1995)::Comedy" & @CRLF & _ "20::Money Train (1995)::Action|Comedy|Crime|Drama|Thriller" Local $sSubst = "" 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