Regular Expressions 101

Save & Share

  • Current Version: 2
  • Update Regex
    ctrl+⇧+s
  • Save new Regex
    ctrl+s
  • Add to Community Library

Flavor

  • PCRE2 (PHP)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java
  • .NET 7.0 (C#)
  • Rust
  • PCRE (Legacy)
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests
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
Processing...

Test String

Code Generator

Generated Code

package main import ( "regexp" "fmt" ) func main() { var re = regexp.MustCompile(`(?m)all\s+(\S+\s+){2}(?<field1>[\d\.]+)`) var str = ` 10/1/2017 0:10:01 all 9.13 0 1.68 6.6 0 82.59 10/1/2017 0:20:01 all 7.46 0 0 5.74 0 85.17 10/1/2017 0:30:01 all 9.05 0 129 1.53 0 88.13 10/1/2017 0:40:01 all 7.77 0 1.45 1.23 0 89.54 10/1/2017 0:50:01 all 7.08 0 1.5 1.41 0 90.02 10/1/2017 1:00:01 all 6.46 0 1.43 1.82 0 90.29 10/1/2017 1:10:01 all 45.4 0 4.2 29.27 0 21.13 10/1/2017 1:20:01 all 61.74 0 4.74 31.19 0 2.32 10/1/2017 1:30:01 all 64.17 0 4.72 26.31 0 4.81 10/1/2017 1:40:01 all 47.54 0 4.23 19.44 0 28.79 10/1/2017 1:50:01 all 44.59 0 3.68 17.47 0 34.27 10/1/2017 2:00:01 all 49.16 0 4.22 13.47 0 33.15 10/1/2017 2:10:01 all 41.98 0 3.95 16.47 0 37.59` 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/