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

/
/
sgm

Test String

Substitution

Processing...

Code Generator

Generated Code

$re = '/(^[a-zA-z0-9]{32})/sm'; $str = '2629f4a363e64a36bbd86c01dfac5168 ff29ac3148394d1bbbcf85a7d0fd27dd c627930216bc439db8563451be4d8172 4ed84dd2bb68430e9c4d43884088b364 84ab4c45d2194651bfa6729ad81cdcb9 6fb2f2de90ab45f4976a699099d30697 2d80f4090d0244b4b92ce505874a5f95 f231e374e45a4f2da1b1dc2c6bcb5991 91d13e50695140a7b4d66a28880986ef 3ef3a3990b5e4870840068b500359fca 43fc4ca5d3a544a49aa0fb6d6e28ceb5 48e54b84562a41f98224773a163c3123 be7f7602169844138ef2a9ab66ac38b6 d2f3b5f91512431b86d943c89fa9b8c4 18ecb09cf4b94e4d91ec1b3efa97ea1f f7ed1df9200543baac16b1e094278f52 f5b54666ccd84b3b905a5092aaf35a48 c6a224f88afe4ebc8943cab7aedd5d21 da180ef24522404598d69e8eb4f071c5 66ae5365d8294605a9cbb6124773d8c4 ba491533d84540e384b4e47280cbdded d38e9d637dca4d6194ff860187ae9059 9113322aa1404a66ba28732ae59e603b '; $subst = "<img src=\"https://vg05.met.vgwort.de/na/$1\" width=\"1\" height=\"1\" alt=\"\">"; $result = preg_replace($re, $subst, $str); echo "The result of the substitution is ".$result;

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