Regular Expressions 101

Save & Share

  • Regex Version: ver. 2
  • Update Regex
    ctrl+⇧+s
  • Save new 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
No Match

`
`
gm

Test String

Code Generator

Generated Code

package main import ( "regexp" "fmt" ) func main() { var re = regexp.MustCompile(`(?m)(\\\w\\\w)|(\\[u][A-Za-z0-9A@#\\(]{4})|([\\][n])`) var str = `@DethDeelinDale DALE BUB⁉️\n\nU ALRIT⁉️\n\nU NEED BAKUP⁉️ RT @DethDeelinDale: WHO N THE FUK R U #DIKS⁉️\n\nHOLEE FUK‼️ PUT DEM \uD83D\uDD2B AWAY!!!\n\nU kan hav the \uD83D\uDCB0 I dun giv a fuk bout dat!!!\n\nHear u go…jus ta… @DethDeelinDale Waz rong dale⁉️\n\nWaz it a menshall er 1 a em lite \uD83D\uDEAC⁉️\n\nI dun HAYT thoz‼️\n\nNuthin but #MarbReds\uD83D\uDEAC 4 me‼️ WAT N THE FLYIN FUK⁉️\n\nHEY, U DUM B!TCH, PULL UP UR FN \uD83D\uDC56‼️\n\nU KANT NOT FRIGGEN \uD83D\uDCA9 HER‼️\n\nI swar 2 fn God, thez #ratards\uD83E\uDD24 @ friggen @Walmart r gonna dun mayk me looz mi fn mind!!! \uD83E\uDD2C\uD83E\uDD2C https://t.co/xsQg26SWIk WOOD U HUREE THE FUK UP U STUPID LITLE KIDS N GET ON UR GOD DAM SKOOL \uD83D\uDE8C!!! \uD83E\uDD2C\n\nU MOTHAFUKERS R GONNA DUN MAYK ME LAYT AGAN 2 MI JOB #HAWLINKARTS\uD83D\uDED2 @Walmart‼️\n\nThas it! I aint not got Tim 4 this, Im passin thez fn ratards!!! \uD83D\uDCA8\n\nOhhhh fukkkkk... \uD83D\uDEA8\uD83D\uDE94\uD83E\uDD26\uD83C\uDFFB‍♂️\uD83E\uDD26\uD83C\uDFFB‍♂️ WAR N TYE FLYIN FUK M I N WAT HAPND 2 MI FN \uD83D\uDC56!!!??? @DethDeelinDale Wat 4 bub⁉️ U dun need mi #glock \uD83D\uDD2B??? RT @DethDeelinDale: I NEEDA #GAT \uD83D\uDD2B‼️ RT @DethDeelinDale: BOOOOOMMMMM‼️ \n\nDAS WAT I THOT #BALDYBILL \uD83D\uDC68\uD83C\uDFFB‍\uD83E\uDDB2‼️\n\nU cum talkin all dat SHIT 2 me n think u waznt gonna get put 2 fukin… Hapins 2 the best a us! \uD83D\uDC56\uD83D\uDCA9 https://t.co/TVzch1v0du RT @HistoryMuppet: This is a brilliant example of the Muppet team going that extra step with a gag \uD83D\uDE02\n(look closely at those “Written By” cr… RT @BroadwayWorld: .@MusicManBway will close on Broadway on January 1, 2023. https://t.co/8sMQ3LUsnA RT @TWJSciNat: Are you feeling lucky? \n\nThe latest episode of Mysteries of Science, starring @DerrenBrown is now live. \n\n\uD83D\uDD17Listen at https:/… RT @JustinRYoung: Very excited to finally release @DontExplainPod, the latest from @DogPonyAudio.\n\nEvery cliche and trope began as a brilli… RT @Justin_Willman: People love me on holidays https://t.co/Ft1udKGydl RT @BroadwaySym: Shana Tova! Wishing eveyone a sweet new year filled w/ many blessings in #stagemanagement &amp; #smlife! May the year bring yo… RT @memgrizz: #BeyondGrit: Making Magic w/ @jacob_laravia3 + @droddy22 \uD83E\uDE84 \n\nIn this episode, LaRavia &amp; Roddy link up with Piff The Magic Dra… RT @BroadwayWorld: Obituary: Rita Gardner, Original Luisa in THE FANTASTICKS, Passes Away at 87\nhttps://t.co/GClzbN6Mii Oh no! Broadway legend \uD83D\uDE22\uD83D\uDE22 RIP https://t.co/J7JXoEmEYZ RT @levarburton: Happy Rosh Hashanah, y’all! #ShanaTova \uD83D\uDC9C\uD83D\uDE4F\uD83C\uDFFE \u@83D \u#123 \u(223` for i, match := range re.FindAllString(str, -1) { fmt.Println(match, "found at index", i) } }

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 Golang, please visit: https://golang.org/pkg/regexp/