Regular Expressions 101

Save & Share

  • Save new Regex
    ctrl+s
  • Update 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
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
  • Match everything enclosed
    (?:...)
  • Capture everything enclosed
    (...)
  • 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"
"
gm

Test String

Code Generator

Generated Code

package main import ( "regexp" "fmt" ) func main() { var re = regexp.MustCompile(`(?m)(?s)(\#\d{1,})(.*?)(\#\d{1,})`) var str = `#0 $dumpvars 0! 0" 0# bxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 7 bxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 6 bxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 5 b0000000000000000 $ bxxxxxxxxxxxxxxxx / bxxxxxxxxxxxxxxxx . bxxxxxxxxxxxxxxxx ) b0111111111111111 % bxxxxxxxxxxxxxxxx 1 bxxxxxxxxxxxxxxxx 0 bxxxxxxxxxxxxxxxx * b10101010101010101010101010101010 & bxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + bxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx , bxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 2 bxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx - bxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 3 bxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 4 bxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ( bxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ' $end #600 1! b0000000000000000 ) b0111111111111111 * b10101010101010101010101010101010 + b0000000000000000 / b0111111111111111 1 b00000000000000000000000000000000 5 b10101010101010101010101010101010 4 b00000000000000000000000000000000 2 b00000000000000000000000000000000 3 b010101010101010101010101010101010 7 #1200 b0000010001010111 $ b0111101110101000 % b10101100101001110100001001010001 & 0! b10101010101010101010101010101010 , b00000000000000000000000000000000 - #1800 1! b0000010001010111 ) b0111101110101000 * b10101100101001110100001001010001 + b010101010101010101010101010101010 ( b010101010101010101010101010101010 ' b0000010001010111 / b00000010001010110111101110101001 5 b0111101110101000 1 b00000010000110001010011000011000 5 b10101100101001110100001001010001 4 b010101100101001110100001001010001 7 b00000010000110001010011000011000 2 b00000010000110001010011000011000 3 b010101110101111111110100001101001 7 #2400 b0000100010101110 $ b0111011101010001 % b10101110101000111101100111111000 & 0! b10101100101001110100001001010001 , b00000010000110001010011000011000 - #3000 1! b0000100010101110 ) b0111011101010001 * b10101110101000111101100111111000 + b010101110101111111110100001101001 ( b010101110101111111110100001101001 ' b0000100010101110 / b00000100001100010100110000110000 5 b0111011101010001 1 b00000100000010111010000100001110 5 b10101110101000111101100111111000 4 b010110000101111001000000000010000 7 b00000100000010111010000100001110 2 b00000100000010111010000100001110 3 b010110010101011110111101100000110 7 #3600 b0000110100000101 $ b0111001011111010 % b10110000101000000111000110011111 & 0! b10101110101000111101100111111000 , b00000100000010111010000100001110 - #4200` 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/