Regular Expressions 101

Save & Share

  • Regex Version: ver. 2
  • 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"
"
gm

Test String

Code Generator

Generated Code

package main import ( "regexp" "fmt" ) func main() { var re = regexp.MustCompile(`(?m)\b,\b|,(?=\d)`) var str = `Review,Liked Wow... Loved this place.,1 Crust is not good.,0 Not tasty and the texture was just nasty.,0 Stopped by during the late May bank holiday off Rick Steve recommendation and loved it.,1 The selection on the menu was great and so were the prices.,1 Now I am getting angry and I want my damn pho.,0 Honeslty it didn't taste THAT fresh.),0 The potatoes were like rubber and you could tell they had been made up ahead of time being kept under a warmer.,0 The fries were great too.,1 A great touch.,1 Service was very prompt.,1 Would not go back.,0 The cashier had no care what so ever on what I had to say it still ended up being wayyy overpriced.,0 I tried the Cape Cod ravoli, chicken, with cranberry...mmmm!,1 I was disgusted because I was pretty sure that was human hair.,0 I was shocked because no signs indicate cash only.,0 Highly recommended.,1 Waitress was a little slow in service.,0 This place is not worth your time, let alone Vegas.,0 did not like at all.,0 The Burrittos Blah!,0 The food, amazing.,1 Service is also cute.,1 I could care less... The interior is just beautiful.,1 So they performed.,1 That's right....the red velvet cake.....ohhh this stuff is so good.,1 #NAME?,0 This hole in the wall has great Mexican street tacos, and friendly staff.,1 Took an hour to get our food only 4 tables in restaurant my food was Luke warm, Our sever was running around like he was totally overwhelmed.,0 The worst was the salmon sashimi.,0 Also there are combos like a burger, fries, and beer for 23 which is a decent deal.,1 This was like the final blow!,0 I found this place by accident and I could not be happier.,1 seems like a good quick place to grab a bite of some familiar pub food, but do yourself a favor and look elsewhere.,0 Overall, I like this place a lot.,1 The only redeeming quality of the restaurant was that it was very inexpensive.,1 Ample portions and good prices.,1 Poor service, the waiter made me feel like I was stupid every time he came to the table.,0 My first visit to Hiro was a delight!,1` 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/