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

/
/
gm

Test String

Code Generator

Generated Code

$re = '/(.*\/)+(.*iRqDU1LMXL)+(.*.txt)/m'; $str = './.git/COMMIT_EDITMSG ./.git/config ./.git/description ./.git/HEAD ./.git/hooks/applypatch-msg.sample ./.git/hooks/commit-msg.sample ./.git/hooks/fsmonitor-watchman.sample ./.git/hooks/post-update.sample ./.git/hooks/pre-applypatch.sample ./.git/hooks/pre-commit.sample ./.git/hooks/pre-merge-commit.sample ./.git/hooks/pre-push.sample ./.git/hooks/pre-rebase.sample ./.git/hooks/pre-receive.sample ./.git/hooks/prepare-commit-msg.sample ./.git/hooks/update.sample ./.git/index ./.git/info/exclude ./.git/logs/HEAD ./.git/logs/refs/heads/master ./.git/logs/refs/remotes/origin/master ./.git/objects/13/c8aa62721dbbacfc0bbbbe470a0ff27809b1ee ./.git/objects/1f/8a712c915070cfcaccdbd280c93f0a34b91d7f ./.git/objects/25/af68d5c360e09db78c2731bf1396b3c28c3a04 ./.git/objects/27/73b847b7575d6b9cf0ff7da81a446644f8561c ./.git/objects/2b/b4512b84eb83060c76953f079883d340fd60bb ./.git/objects/2e/8f98c0236e13fc9026c2081577339c4de09b14 ./.git/objects/45/b243749feb2b7ddb53041689f2f7c3fb47c18e ./.git/objects/4a/d36799bf97fd236782c1c7fe3468d40683f8d4 ./.git/objects/4b/6a570fc59cf271ca3abf4c59007abc327ef044 ./.git/objects/4d/c86b78e7cd49415c2d54464fac5903937e9fb2 ./.git/objects/54/94c0017ff26ffb7f31006c627ed7f8efaffc47 ./.git/objects/55/0b0797664a3bee84d197917c2744cf532d981e ./.git/objects/63/9ebadc03dffd3f458827ad9473e37a064b163c ./.git/objects/64/32e28da5e3e2018684f1ec2ef42073fd1b41c7 ./.git/objects/75/77615205b7471787020ea317c9a65a5c139661 ./.git/objects/83/f4568bf2d6d0a055dea61aeb8c6826fa0d94e7 ./.git/objects/8d/b3634d8dc58f18a159805d405a81fd41dcdd55 ./.git/objects/9c/732bcf358fc6dcee4175649d8bcdbf4e31e591 ./.git/objects/a5/66d64d37890189c02a95427a54a8f0ef2940fe ./.git/objects/a6/0e058b9a2c34a3fcd8b668e745bf5d4f31833c ./.git/objects/a6/2dc150c4dbe7299e3de32dbbdb3700e72f8e2a ./.git/objects/a8/c9163b6f76a304dfaef02b24c0e4633945b87b ./.git/objects/ba/e51b287f66d1954be1299716ade870958c7951 ./.git/objects/bc/caec878124c81a2e5b6b93d9f9b2a92ce1e9ec ./.git/objects/d4/3a941d910623bc0b1061485f1c03d7b3e131d2 ./.git/objects/e2/9a425487ef15eb3d9c71ce08ac6667d7129a04 ./.git/objects/e4/1702a858128ed2049e3175b633ce4f7d633069 ./.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 ./.git/objects/e7/e04aaf9938c23f912d762f28982b99fa962a26 ./.git/objects/e9/f9698e092b85adaf41063f871350b9292eba29 ./.git/objects/fb/3d1d5c020fc8486cf34b142de1541f78aebe59 ./.git/objects/fb/bc03043aaa99c42d0c7b9eb76a1941f786e1ec ./.git/objects/fe/f3e61fef5c2dc198429d319feb9b95915cd73c ./.git/refs/heads/master ./.git/refs/remotes/origin/master ./codecs/ulaw.go ./ffmpeg/ffmpeg.go ./ffmpeg/funcMergeVideo.txt ./ffmpeg/making.go ./go.mod ./go.sum ./main.go ./metadata/rtpengine-meta-iRqDU1LMXL-722138ce4b791218.txt ./output/39485c3955d3e1067fe66b1e34284d7d-receiving-client.mp4 ./output/39485c3955d3e1067fe66b1e34284d7d-receiving-server.mp4 ./pcap/39485c3955d3e1067fe66b1e34284d7d%40203.150.245.42%3A5060-83b08021214f9a0c.pcap ./pcap/iRqDU1LMXL-722138ce4b791218.pcap ./pcap/test01.pcap ./README.md ./splitsdp/splitsdp.go ./stream/stream.go'; preg_match_all($re, $str, $matches, PREG_SET_ORDER, 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