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 (74)

Tools

Sponsors
There are currently no sponsors. Become a sponsor today!
An explanation of your regex will be automatically generated as you type.
  • 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

`
`
gmx

Unit Tests

given the string http://10.1.1.1 assert that regex does not match
given the string http://.www.foo.bar./ assert that regex does not match
given the string http://www.foo.bar./ assert that regex does not match
given the string http://.www.foo.bar/ assert that regex does not match
given the string http://3628126748 assert that regex does not match
given the string http://123.123.123 assert that regex does not match
given the string http://1.1.1.1.1 assert that regex does not match
given the string http://224.1.1.1 assert that regex does not match
given the string http://10.1.1.255 assert that regex does not match
given the string http://10.1.1.0 assert that regex does not match
given the string http://0.0.0.0 assert that regex does not match
given the string http://a.b-.co assert that regex does not match
given the string http://-a.b.co assert that regex does not match
given the string http://a.b--c.de/ assert that regex does not match
given the string http://-error-.invalid/ assert that regex does not match
given the string ftps://foo.bar/ assert that regex does not match
given the string http://foo.bar/foo(bar)baz quux assert that regex does not match
given the string :// should fail assert that regex does not match
given the string http:// shouldfail.com assert that regex does not match
given the string h://test assert that regex does not match
given the string rdar://1234 assert that regex does not match
given the string foo.com assert that regex does not match
given the string http:///a assert that regex does not match
given the string /// assert that regex does not match
given the string ///a assert that regex does not match
given the string //a assert that regex does not match
given the string // assert that regex does not match
given the string http://foo.bar?q=Spaces should be encode… assert that regex does not match
given the string http://##/ assert that regex does not match
given the string http://## assert that regex does not match
given the string http://# assert that regex does not match
given the string http://??/ assert that regex does not match
given the string http://?? assert that regex does not match
given the string http://? assert that regex does not match
given the string http://../ assert that regex does not match
given the string http://.. assert that regex does not match
given the string http://. assert that regex does not match
given the string http:// assert that regex does not match
given the string http://223.255.255.254 assert that regex does match
given the string http://a.b-c.de assert that regex does match
given the string http://1337.net assert that regex does match
given the string http://-.~_!$&'()*+,;=:%40:80%2f::::::@e… assert that regex does match
given the string http://उदाहरण.परीकॅ assert that regex does match
given the string http://例子.测试 assert that regex does match
given the string http://مثال.إختبار assert that regex does match
given the string http://foo.bar/?q=Test%20URL-encoded%20s… assert that regex does match
given the string ftp://foo.bar/baz assert that regex does match
given the string http://j.mp assert that regex does match
given the string http://code.google.com/events/#&product=… assert that regex does match
given the string http://☺.damowmow.com/ assert that regex does match
given the string http://foo.com/(something)?after=parens assert that regex does match
given the string http://foo.com/unicode_(✪)_in_parens assert that regex does match
given the string http://foo.com/blah_(wikipedia)_blah#cit… assert that regex does match
given the string http://foo.com/blah_(wikipedia)#cite-1 assert that regex does match
given the string http://⌘.ws/ assert that regex does match
given the string http://⌘.ws assert that regex does match
given the string http://➡.ws/䨹 assert that regex does match
given the string http://142.42.1.1:8080/ assert that regex does match
given the string http://142.42.1.1/ assert that regex does match
given the string http://userid:password@example.com/ assert that regex does match
given the string http://userid:password@example.com assert that regex does match
given the string http://userid@example.com:8080/ assert that regex does match
given the string http://userid@example.com:8080 assert that regex does match
given the string http://userid@example.com/ assert that regex does match
given the string http://userid@example.com assert that regex does match
given the string http://userid:password@example.com:8080/ assert that regex does match
given the string http://userid:password@example.com:8080 assert that regex does match
given the string http://✪df.ws/123 assert that regex does match
given the string https://www.example.com/foo/?bar=baz&ing… assert that regex does match
given the string http://www.example.com/wpstyle/?p=364 assert that regex does match
given the string http://foo.com/blah_blah_(wikipedia)_(ag… assert that regex does match
given the string http://foo.com/blah_blah_(wikipedia) assert that regex does match
given the string http://foo.com/blah_blah/ assert that regex does match
given the string http://foo.com/blah_blah assert that regex does match

Regex Debugger

Please wait while your expression is being debugged...