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

/
/
gmis

Test String

Code Generator

Generated Code

package main import ( "regexp" "fmt" ) func main() { var re = regexp.MustCompile(`(?mis)^const labels(.*)const config = {type: 'line',data: data,options: {}};`) var str = ` <script src="/js/theme.min-1.1.js"></script><script> const labels = [ '00:00','01:00','02:00','03:00','04:00','05:00','06:00','07:00','08:00','09:00','10:00','11:00','12:00','13:00','14:00','15:00','16:00','17:00','18:00','19:00','20:00','21:00','22:00','23:00','24:00',]; const data = { labels: labels, datasets: [{ stepped:true, label: 'Idag', backgroundColor: '#357DA7', borderColor: '#357DA7', data: [94.24,91.59,93.52,97.70,103.23,155.15,233.20,269.03,279.92,255.87,231.30,226.70,209.64,174.65,164.84,154.16,134.04,199.48,205.03,204.88,192.49,154.16,74.40,19.47,19.47] }, { label: 'Idag snitt', backgroundColor: '#fff', borderColor: '#357DA7', borderDash: [5, 5], data: [167.44,167.44,167.44,167.44,167.44,167.44,167.44,167.44,167.44,167.44,167.44,167.44,167.44,167.44,167.44,167.44,167.44,167.44,167.44,167.44,167.44,167.44,167.44,167.44,167.44,], pointRadius: 0, borderWidth: 2 } ,{ stepped:true, label: 'Imorgon', backgroundColor: '#dd4b39', borderColor: '#dd4b39', data: [10.28,9.82,6.15,5.10,11.91,13.78,80.03,205.79,215.04,214.14,211.85,205.64,204.86,165.63,166.62,196.70,200.63,207.10,211.79,211.80,208.24,207.02,113.90,47.63,47.63] },{ label: 'Imorgon snitt', backgroundColor: '#fff', borderColor: '#dd4b39', borderDash: [5, 5], data: [138.81,138.81,138.81,138.81,138.81,138.81,138.81,138.81,138.81,138.81,138.81,138.81,138.81,138.81,138.81,138.81,138.81,138.81,138.81,138.81,138.81,138.81,138.81,138.81,138.81,], pointRadius: 0, borderWidth: 2 } ] }; const config = {type: 'line',data: data,options: {}}; var myChart = new Chart(document.getElementById('myChart'),config); </script>` 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/