Regular Expressions 101

Save & Manage Regex

  • Current Version: 1
  • Save & Share
  • 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(`(?mU)(?<phone>(380(?:\(|\)|\-|\_|\[|\]|\s+){0,3}((([38]9|4(?:[45][0-5]|87)|5(?:0|6(?:3[14-7]|7)|7[37])|6[36-8]|73|9[1-9])(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d)|((3(?:[1-46-8]2[013-9]|52)|4(?:[1378]2|62[013-9])|5(?:[12457]2|6[24])|6(?:[49]2|[12][29]|5[24])|8[0-8]|90)(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d)|((3(?:5[013-9]|[1-46-8](?:22|[013-9]))|4(?:[137][013-9]|6(?:[013-9]|22)|[45][6-9]|8[4-6])|5(?:[1245][013-9]|6(?:3[02389]|[015689])|3|7[4-6])|6(?:[49][013-9]|5[0135-9]|[12][13-8]))(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d)))|((0(?:\(|\)|\-|\_|\[|\]|\s+){0,3}([38]9|4(?:[45][0-5]|87)|5(?:0|6(?:3[14-7]|7)|7[37])|6[36-8]|73|9[1-9])(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3})|(0(?:\(|\)|\-|\_|\[|\]|\s+){0,3}(3(?:[1-46-8]2[013-9]|52)|4(?:[1378]2|62[013-9])|5(?:[12457]2|6[24])|6(?:[49]2|[12][29]|5[24])|8[0-8]|90)(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3})|(0(?:\(|\)|\-|\_|\[|\]|\s+){0,3}(3(?:5[013-9]|[1-46-8](?:22|[013-9]))|4(?:[137][013-9]|6(?:[013-9]|22)|[45][6-9]|8[4-6])|5(?:[1245][013-9]|6(?:3[02389]|[015689])|3|7[4-6])|6(?:[49][013-9]|5[0135-9]|[12][13-8]))(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3}\d(?:\(|\)|\-|\_|\[|\]|\s+){0,3})))`) var str = `066 12 345 67 38 066 123 45 67 38( 066 ) 12 - 34 - 567` 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/