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

/
/
ig

Test String

Substitution

Processing...

Code Generator

Generated Code

package main import ( "regexp" "fmt" ) func main() { var re = regexp.MustCompile(`(?i)(?:.*?:(".*?"))|(.*)`) var str = `{"maps":{"idOthers":{"label":"Others","state":1,"bkmrk":{}}},"portals":{"id1472374017624":{"label":"Teslin, YT","state":1,"bkmrk":{"id1471384290640":{"guid":"1c742997732a404190ad947a1e2ad1f1.12","latlng":"60.176809,-132.790461","label":"Teslin Heritage Centre, Yt - j"},"id1471384292759":{"guid":"0ff8105df28b4291bb388bb3169992b0.16","latlng":"60.167183,-132.707912","label":"Moose And Caribou Replica"},"id1471384291685":{"guid":"80e38740843f43489e5c3b9bcb4017e6.16","latlng":"60.16109,-132.693209","label":"Village of Teslin Gazebo"},"id1471384293782":{"guid":"71e8bd86f50c4fd9844f3d4091b92325.16","latlng":"60.167443,-132.707359","label":"Wildlife Gallery"}}},"id1472374213379":{"label":"Watson Lake, YT","state":1,"bkmrk":{"id1472374223764":{"guid":"32b7435123914d6d8c470f1c9c3d03b2.16","latlng":"60.066292,-128.704744","label":"Wye Lake Gazebo"},"id1472374224152":{"guid":"52f7f7cbac894342a5e83a97a46c7422.16","latlng":"60.065734,-128.705368","label":"Wye Lake Park"},"id1472374224529":{"guid":"04b586b6c30c42ce84bdb7f85d9f2d16.16","latlng":"60.065442,-128.704187","label":"Horned & Common Dandelions"},"id1472374225092":{"guid":"f657a17af2dc48c6966aa32a83f2b1f9.16","latlng":"60.062886,-128.7068","label":"First Wye Lake Park"},"id1472374225511":{"guid":"33498408d348447d9cde3fdb180dc038.16","latlng":"60.064183,-128.714208","label":"Watson Lake Information Center"},"id1472374225978":{"guid":"da5df8fb86d44476b4372ba0295ae2af.12","latlng":"60.063748,-128.715488","label":"Watson Lake Sign Post Forest -"},"id1472374226806":{"guid":"33f693fa6735446a8d848300487b46f0.16","latlng":"60.065042,-128.713877","label":"Watson Lake Recreation Centre"},"id1472374227184":{"guid":"e968d06b86264aae882b41038e6c19c1.16","latlng":"60.06444,-128.715315","label":"Robert Campbell Highway Information"},"id1472374223273":{"guid":"84d9bc723f7c4d7e98a7a62ec86f7a68.16","latlng":"60.062733,-128.704699","label":"Watson Lake Library"}}},"idOthers":{"label":"Others","state":1,"bkmrk":{"id1472374171311":{"guid":"445808e24dd840d5b24b407edd8f664b.16","latlng":"60.027705,-129.080566","label":"Native Outlook"},"id1472374176673":{"guid":"184a20a3b1694bf68c89354680d7b674.16","latlng":"60.027904,-129.080963","label":"Nugget Totem"}}}}} ` var substitution = "$1" fmt.Println(re.ReplaceAllString(str, substitution)) }

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/