Regular Expressions 101

Save & Share

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 single character of: a, b, c or d
    [[ab][cd]]
  • 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]
  • Character class intersection
    [\w&&[^\d]]
  • 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

"
"
gm

Test String

Code Generator

Generated Code

package main import ( "regexp" "fmt" ) func main() { var re = regexp.MustCompile(`(?m)((?<A>\s(greater|less|earlier)\sth[a|e]n)((?<B>\sor equal)[s]?)?(\sto)?\s)(?<V>[^\s]+)?`) var str = `Check if the version of xpsviewer.exe is greater than or equal to 3.0.6920.7000 Check if OpenSSL 1.1.0 version is greater than or equal 1.1.0 and less than 1.1.0e Check if Oracle VM VirtualBox version is greater than or equals to 3.2.0 Version of VLC Media Player less than or equal to 2.0.4 Check if Java SE Development Kit 1.6 version is less than or equal 6.0.1710 Version of VLC Media Player greater than or equal to 0.5.0 and less than or equal to 0.9.5 the version of cryptdlg.dll is less then 5.0.1558.6072 Check if the version of Microsoft.sqlserver.chainer.infrastructure.dll is less than 14.0.2000.63 and greater than 14.0.0 Check if OpenSSL version is less than or equals to 0.9.8.24 in VisualSVN Server Determine if the version of JavaFX is less than 2.2.46 (JRE 1.7.0:update_6 and later) Mozilla Firefox ESR version is less than 24.1 and greater than or equal to 24.x Check if SQL Server instances with version less than 2009.100.4000.0 and greater than or equal 2009.100.2500.0 Excel 2000 SP3 or greater is installed Mozilla Firefox version 3.5.x to 3.5.1 or less than 3.0.14 Check if ssleay32.dll 1.0.1 version is greater than or equal 1.0.1 and less than 1.0.1u on ProgramFilesDir (x86) Check if SQL Server instances with version greater than or equal 2007.100.6000.0 and less than 2009.100.1600.1 exist Check if outlook.exe version is greater than or equal to 16.0.8201.0000 and less than 16.0.8201.2213 (MSO 2016 Version 1705) firefox DPKG is earlier than 0:32.0+build1-0ubuntu0.12.04.1 openjdk-7-jre-headless DPKG is earlier than 0:7u65-2.5.1-4ubuntu1~0.14.04.1 kvm DPKG is earlier than 84+dfsg-0ubuntu16+0.12.3+noroms+0ubuntu9.4 Check if the version of ssleay32.dll 0.9.1c before 0.9.8y ProgramFilesDir x86 Check if the version of OpenSSL 0.9.1c before 0.9.8s (32_bit) Version of Wireshark is 1.4.x before 1.4.15, 1.6.x before 1.6.10, or 1.8.x before 1.8.2 Version of Wireshark is 1.8.x before 1.8.10 or 1.10.x before 1.10.2 Check if the version of PHP is less than 5.2.15 or 5.3.x before 5.3.4 ` 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/