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 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"
"

Test String

Code Generator

Generated Code

$re = '/Hash: 0xcba5ee76d1b322114c4e5b1a3e00edf1065bf0346bef88ee603a8a061908db88https://img.shields.io/azure-devops/coverage/0xb95343413e459a0f97461812111254163ae53467855c0d73e0f1e7c5b8442fa3/https://tokenview.com/en/search/0xdf6ac64b05e8bb7ca5c8d31ff44a00544eb039a7f467a424ae1c1e1926f19684/974618121112?color=https%3A%2F%2Fimg.shields.io%2Fazure-devops%2Fcoverage%2F0xb95343413e459a0f97461812111254163ae53467855c0d73e0f1e7c5b8442fa3%2Fhttps%3A%2F%2Ftokenview.com%2Fen%2Fsearch%2F0xdf6ac64b05e8bb7ca5c8d31ff44a00544eb039a7f467a424ae1c1e1926f19684%2F974618121112&label=%3Cimg%20alt%3D%22Azure%20DevOps%20coverage%22%20src%3D%22https%3A%2F%2Fimg.shields.io%2Fazure-devops%2Fcoverage%2F0xb95343413e459a0f97461812111254163ae53467855c0d73e0f1e7c5b8442fa3%2Fhttps%3A%2F%2Ftokenview.com%2Fen%2Fsearch%2F0xdf6ac64b05e8bb7ca5c8d31ff44a00544eb039a7f467a424ae1c1e1926f19684%2F974618121112%22%3E&logo=0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2&logoColor=https%3A%2F%2Ftokenview.com%2Fen%2Fsearch%2F0xdf6ac64b05e8bb7ca5c8d31ff44a00544eb039a7f467a424ae1c1e1926f19684&style=plastic/'; $str = 'https://img.shields.io/azure-devops/coverage/0xb95343413e459a0f97461812111254163ae53467855c0d73e0f1e7c5b8442fa3/https://tokenview.com/en/search/0xdf6ac64b05e8bb7ca5c8d31ff44a00544eb039a7f467a424ae1c1e1926f19684/974618121112?color=https%3A%2F%2Fimg.shields.io%2Fazure-devops%2Fcoverage%2F0xb95343413e459a0f97461812111254163ae53467855c0d73e0f1e7c5b8442fa3%2Fhttps%3A%2F%2Ftokenview.com%2Fen%2Fsearch%2F0xdf6ac64b05e8bb7ca5c8d31ff44a00544eb039a7f467a424ae1c1e1926f19684%2F974618121112&label=%3Cimg%20alt%3D%22Azure%20DevOps%20coverage%22%20src%3D%22https%3A%2F%2Fimg.shields.io%2Fazure-devops%2Fcoverage%2F0xb95343413e459a0f97461812111254163ae53467855c0d73e0f1e7c5b8442fa3%2Fhttps%3A%2F%2Ftokenview.com%2Fen%2Fsearch%2F0xdf6ac64b05e8bb7ca5c8d31ff44a00544eb039a7f467a424ae1c1e1926f19684%2F974618121112%22%3E&logo=0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2&logoColor=https%3A%2F%2Ftokenview.com%2Fen%2Fsearch%2F0xdf6ac64b05e8bb7ca5c8d31ff44a00544eb039a7f467a424ae1c1e1926f19684&style=plastic.. image:: https://img.shields.io/azure-devops/coverage/0xb95343413e459a0f97461812111254163ae53467855c0d73e0f1e7c5b8442fa3/https://tokenview.com/en/search/0xdf6ac64b05e8bb7ca5c8d31ff44a00544eb039a7f467a424ae1c1e1926f19684/974618121112?color=https%3A%2F%2Fimg.shields.io%2Fazure-devops%2Fcoverage%2F0xb95343413e459a0f97461812111254163ae53467855c0d73e0f1e7c5b8442fa3%2Fhttps%3A%2F%2Ftokenview.com%2Fen%2Fsearch%2F0xdf6ac64b05e8bb7ca5c8d31ff44a00544eb039a7f467a424ae1c1e1926f19684%2F974618121112&label=%3Cimg%20alt%3D%22Azure%20DevOps%20coverage%22%20src%3D%22https%3A%2F%2Fimg.shields.io%2Fazure-devops%2Fcoverage%2F0xb95343413e459a0f97461812111254163ae53467855c0d73e0f1e7c5b8442fa3%2Fhttps%3A%2F%2Ftokenview.com%2Fen%2Fsearch%2F0xdf6ac64b05e8bb7ca5c8d31ff44a00544eb039a7f467a424ae1c1e1926f19684%2F974618121112%22%3E&logo=0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2&logoColor=https%3A%2F%2Ftokenview.com%2Fen%2Fsearch%2F0xdf6ac64b05e8bb7ca5c8d31ff44a00544eb039a7f467a424ae1c1e1926f19684&style=plastic :alt: Azure DevOps coverage<img alt="Azure DevOps coverage" src="https://img.shields.io/azure-devops/coverage/0xb95343413e459a0f97461812111254163ae53467855c0d73e0f1e7c5b8442fa3/https://tokenview.com/en/search/0xdf6ac64b05e8bb7ca5c8d31ff44a00544eb039a7f467a424ae1c1e1926f19684/974618121112">https://img.shields.io/azure-devops/coverage/0xb95343413e459a0f97461812111254163ae53467855c0d73e0f1e7c5b8442fa3/https://tokenview.com/en/search/0xdf6ac64b05e8bb7ca5c8d31ff44a00544eb039a7f467a424ae1c1e1926f19684/974618121112https://tokenview.com/en/search/0xdf6ac64b05e8bb7ca5c8d31ff44a00544eb039a7f467a424ae1c1e1926f196840xb95343413e459a0f97461812111254163ae53467855c0d73e0f1e7c5b8442fa3'; preg_match($re, $str, $matches, PREG_OFFSET_CAPTURE, 0); // Print the entire match result var_dump($matches);

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 PHP, please visit: http://php.net/manual/en/ref.pcre.php