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

/
/
gm

Test String

Substitution

Processing...

Code Generator

Generated Code

#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox Local $sRegex = "(?m)^"(.*)" (.*), (.*)" Local $sString = "Description" & @CRLF & _ ""Mulligan" neutered male, Brindle Bullmastiff" & @CRLF & _ ""Tiny" male, tan and white Boxer mix" & @CRLF & _ ""Charlie" neutered male, black and white Labrador Retriever mix " & @CRLF & _ ""Nala" spayed female, white and brown brindle Pit Bull mix" & @CRLF & _ ""Lexie" female, white and black Pit Bull " & @CRLF & _ ""Holly" Spayed female, white Labrador/Pitbull mix" & @CRLF & _ ""Lincoln" male, fawn and white Pit Bull Terrier" & @CRLF & _ ""Sparkles" spayed female, Brindle Plott Hound mix" & @CRLF & _ ""Missy" Spayed Female, red/white Pitbull mix" & @CRLF & _ ""Rita" female, brown Australian Shepherd " & @CRLF & _ ""Miles Davis" female, gold/white Golden Retriever " & @CRLF & _ ""Lacy" spayed female, Labrador Retriever Mix" & @CRLF & _ ""Clementine" spayed female, black and white Austrailian Cattle dog" & @CRLF & _ ""Coronel" Male, Tan/Black German Shepherd mix" & @CRLF & _ ""Lady Bug" spayed female, white/black Pit bull/Jack Russell mix" & @CRLF & _ ""Buddy" male, blue brindle and white Pitbull mix" & @CRLF & _ ""Boomer" neutered brown Pit Bull Mix" & @CRLF & _ ""Weezer" female, Tan/Brown German Shepherd" & @CRLF & _ ""Little Girl" spayed female, brown brindle and white Bull Terrier" & @CRLF & _ ""Diva" intact female, tri-color Pit Bull" & @CRLF & _ ""Jack" neutered male, red/white Labrador Retriever mix " & @CRLF & _ ""Salty" male, brown and white Boxer" & @CRLF & _ ""G" male, brown Pit Bull/Boxer mix " & @CRLF & _ ""Keely" spayed female, Red Labrador Retriever mix" & @CRLF & _ ""Tyson" neutered male, German Shepherd" & @CRLF & _ ""Tug" male, brown merle and white Queensland Heeler mix" & @CRLF & _ ""Shebba" female, white Pit Bull mix " & @CRLF & _ ""Blue" male, blue Pit Bull mix" & @CRLF & _ ""Pinky" female, white Boxer mix" & @CRLF & _ ""Ladybird" Spayed female, yellow brindle and white Pit Bull mix" & @CRLF & _ ""Dozer" neutered male, white and red Rhodesian Ridgeback" & @CRLF & _ ""Lahlo" spayed female, tan Boxer mix" & @CRLF & _ ""Maya" spayed female, brown/white Pitbull mix" & @CRLF & _ ""Cinnamon" female, red and white Border Collie " & @CRLF & _ ""Taz" neutered male, brown brindle Boxer mix" & @CRLF & _ ""Lily" female, black and white Chihuahua" & @CRLF & _ ""Abbo" neutered male, white/brown Great Pyrenees mix " & @CRLF & _ ""Milo" neutered male, white/brown, German Short-haired Pointer" & @CRLF & _ ""Lia" spayed female, white/black Pit Bull/Jack Russell mix" & @CRLF & _ ""Sissy" female, tan and black German Shepherd" & @CRLF & _ ""Nippy" female, black and tan Shepherd mix" & @CRLF & _ ""Ginger" spayed female, red and white American Fox Terrier mix" & @CRLF & _ ""Jonah" female, brown and white Pit Bull mix" & @CRLF & _ ""Diego" neutered male, cream and white Great Pyrenees" & @CRLF & _ ""June" female, Brindle Pit Bull Terrier " & @CRLF & _ ""Maia" female, white/tan Pit Bull mix" & @CRLF & _ ""Iko" neutered male, Brown Brindle Catahoula mix" & @CRLF & _ ""Zues" neutered male, blue and white Great Dane" & @CRLF & _ ""Tank" neutered, black/grey German Wire-haired Pointer " & @CRLF & _ ""Bumpy" neutered male, white and black Bull Terrier" & @CRLF & _ ""Negro" neutered male, black, tan and white Chihuahua mix" & @CRLF & _ ""Lucy" spayed female, brown brindle and white Boxer mix" & @CRLF & _ ""Austin" male, red merle Australian Shepherd" & @CRLF & _ ""Aries" spayed female, blue Cane Corso" & @CRLF & _ ""Bella" spayed female, Tan and White Pit Bull mix" & @CRLF & _ ""Gucio" male, black Giant Schnauzer" & @CRLF & _ ""Kilo" neutered male, red and white Pit Bull mix" & @CRLF & _ ""Chuy" spayed female, brown brindle and white Boxer mix" & @CRLF & _ ""Flint" neutered male, blue Blue Lacy mix" & @CRLF & _ ""Sydney" spayed female, Tricolor/Black Beagle " & @CRLF & _ ""Sunny" Neutered Male, Brown/Tan Shepherd mix" & @CRLF & _ ""Lucky" male, black and tri-colored Chihuahua" & @CRLF & _ ""Cleo" female, black Labrador Retriever mix " Local $sSubst = "$1\t$2\t$3" 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