Regular Expressions 101

Save & Share

  • Regex Version: ver. 1
  • 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

r"
"
gms

Test String

Code Generator

Generated Code

package main import ( "regexp" "fmt" ) func main() { var re = regexp.MustCompile(`(?ms)##Player Stats\n(.*?)##Goalie Stats`) var str = `[](#startinjuredreserve) ##Injured Reserve |Position|Player|Salary| |:-|:-|:-| |RD|Oscar Fantenberg|$850,000| |LW|Antoine Roussel|$3,000,000| [](#endinjuredreserve) [](#startmagicalbotarea) ##Schedule |Date|Time|Opponent|TV/Score| |::|::|::|::| |15 Oct|19:00|vs [Detroit Red Wings](/r/detroitredwings "Detroit Red Wings")|**W 5-1**| |17 Oct|17:00|@ [St. Louis Blues](/r/stlouisblues "St. Louis Blues")|**W 4-3**| |19 Oct|10:00|@ [New Jersey Devils](/r/devils "New Jersey Devils")|L 1-0| |**Today**|10:00|@ [New York Rangers](/r/rangers "New York Rangers")|**W 3-2**| |22 Oct|16:30|@ [Detroit Red Wings](/r/detroitredwings "Detroit Red Wings")|SN360| |25 Oct|19:00|vs [Washington Capitals](/r/caps "Washington Capitals")|SN1| |28 Oct|19:00|vs [Florida Panthers](/r/floridapanthers "Florida Panthers")|SNP| ##Pacific Standings |Team|GP|W|L|OTL|PTS|Streak |::|::|::|::|::|::|::| |[Edmonton Oilers](/r/edmontonoilers "Edmonton Oilers")|8|7|1|0|14|W2| |[Anaheim Ducks](/r/anaheimducks "Anaheim Ducks")|8|6|2|0|12|W2| |[Vegas Golden Knights](/r/goldenknights "Vegas Golden Knights")|9|6|3|0|12|W2| |[Vancouver Canucks](/r/canucks "Vancouver Canucks")|8|5|3|0|10|W1| |[Arizona Coyotes](/r/coyotes "Arizona Coyotes")|7|4|2|1|9|W3| |[Calgary Flames](/r/calgaryflames "Calgary Flames")|9|4|4|1|9|L1| |[San Jose Sharks](/r/sanjosesharks "San Jose Sharks")|8|3|5|0|6|L1| |[Los Angeles Kings](/r/losangeleskings "Los Angeles Kings")|8|3|5|0|6|W1| ##Player Stats Player|GP|G|A|P|+/-|PIM| |:|::|::|::|::|::|::| |Miller|8|4|4|**8**|5|4| |Pettersson|8|2|6|**8**|4|0| |Boeser|8|2|5|**7**|4|0| |Edler|8|3|3|**6**|-1|10| |Sutter|8|2|3|**5**|1|7| |Pearson|8|2|2|**4**|-4|2| |Tanev|8|1|3|**4**|1|0| |Hughes|8|1|3|**4**|1|2| |Horvat|8|2|1|**3**|0|2| |Leivo|8|1|2|**3**|1|2| ##Goalie Stats |Goalie|GP|W|L|SV%|GAA|SO| |:|::|::|::|::|::|::| |Markstrom|5|3|2|0.932|2.19|0| |Demko|3|2|1|0.943|1.64|0| ***** Updated at: 20 Oct 2019, 03:12 PM PST ***** [](#endmagicalbotarea) ##Filter Options - If you want to block a certain type of posts, click one of the link filters below - [No Shitpost/Memes](https://nm.reddit.com/r/canucks/#nm) - [No Fan Content](https://nf.reddit.com/r/canucks/#nf) - [No Memes or Fan Content](https://mf.reddit.com/r/canucks/#mf) - [Reset Filter](https://reddit.com/r/canucks/) ## Links & Resources - /r/hockey - /r/UticaComets - /r/TheAthleticVAN - [Canucks Capfriendly](https://www.capfriendly.com/teams/canucks) - [Canucks.com](https://www.nhl.com/canucks) - [Canucks Official Twitter](https://twitter.com/canucks) - [Canucks Official YT Channel](http://www.youtube.com/user/Canucks) - [Sportsnet 650 Vancouver](http://www.sportsnet.ca/650/) - [TSN 1040](http://www.tsn.ca/radio/vancouver-1040-i-1410) - [**Join /r/Canucks Discord!**] (https://discord.gg/UTZ5Vrb) ## Subreddit Wiki - [Rules and Guidelines](/r/canucks/wiki/rules) - [Streaming Guide](/r/canucks/wiki/streaming) - [Attending a Canucks Game?](/r/canucks/comments/2u5lxr/so_you_wanna_go_to_a_canucks_game_eh_faq_for/) - [Canucks Resources](/r/canucks/wiki/resources) - [Meme Hall of Fame](/r/canucks/wiki/memes) - [AMA Archive](/r/canucks/wiki/amas) - [**Nostalgia Corner**](https://www.reddit.com/r/canucks/wiki/nostalgia-corner)` 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/