Regular Expressions 101

Save & Share

  • Current Version: 1
  • Update Regex
    ctrl+⇧+s
  • Save new Regex
    ctrl+s
  • Add to Community Library

Flavor

  • PCRE2 (PHP)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java
  • .NET 7.0 (C#)
  • Rust
  • PCRE (Legacy)
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests
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
Processing...

Test String

Code Generator

Generated Code

$re = '/(gmail\.com)/m'; $str = '{"AffectedItems": [{"Attachments": "1\\u071b\\u0738\\u0771\\u0771 \\u073f\\u0770\\u073e \\u0738\\u0786\\u0737\\u0771\\u0770\\u0771\\u073c\\u0786\\u0771\\u0771\\u077c \\u0737\\u073c\\u0786\\u073c.doc (31678b); \\u071e\\u073f\\u0738\\u0771\\u0770\\u0788\\u0899\\u031f\\u077c\\u073c\\u0738\\u073a.docx (89816b)", "Id": "JCNAAAA18PlntFTRK9sdgawlMkwpMNkwL/J8j7e08jBSJnska8+0AAAAAAEJAADpG/J8j7e08jBSJnska8+0AAGYRCBwAAAA", "InternetMessageId": "<EU0PR86MB137886DDV1833778ABCDE3EC8F8B0@EU0PR86MB1378.ampprd08.prod.outlook.com>", "ParentFolder": {"Id": "JCNAAAA18PlntFTRK9sdgawlMkwpMNkwL/J8j7e08jBSJnska8+1BBBBBBCRDDDDC", "Path": "\\\\\\u070a\\u0899\\u0737\\u0786\\u0771\\u031f\\u0899\\u073c\\u0786"}, "Subject": "FW: \\u071f\\u0738\\u0770\\u0738\\u0786\\u0737\\u0738\\u073c\\u0771\\u0738\\u0777\\u0786\\u073a\\u0899\\u0776\\u0786\\u077f \\u0788\\u071e\\u0718 \\"\\u0718\\u0706\\u0780\\u0710-\\u0788\\u0718\\u0788\\u070a\\u071e\\" \\u0707\\u0717\\u0780\\u071f\\u071e\\u0783: 33771737"}, {"Id": "JCNAAAA18PlntFTRK9sdgawlMkwpMNkwL/J8j7e08jBSJnska8+0AAAAAAEJAADpG/J8j7e08jBSJnska8+0AAGYRCBxAAAA", "InternetMessageId": "<EU0PR86MB13781BA33879ECE7B1D0C90D8F7A0@EU0PR86MB1378.ampprd08.prod.outlook.com>", "ParentFolder": {"Id": "JCNAAAA18PlntFTRK9sdgawlMkwpMNkwL/J8j7e08jBSJnska8+1BBBBBBCRDDDDC", "Path": "\\\\\\u070a\\u0899\\u0737\\u0786\\u0771\\u031f\\u0899\\u073c\\u0786"}, "Subject": "RE: 83731031 \\u0788\\u071e\\u0718\\"\\u0718\\u0719\\u0787 \\u0718\\u071b \\u0711\\u0706 \\u078e\\u071a\\u0780\\u0718\\u0719\\u070a\\" 3 000.00 EUR_\\u0737\\u0899\\u0770\\u0899\\u0778\\u073e\\u0738\\u0899\\u073c\\u073e"}, {"Id": "JCNAAAA18PlntFTRK9sdgawlMkwpMNkwL/J8j7e08jBSJnska8+0AAAAAAEJAADpG/J8j7e08jBSJnska8+0AAGaVnGNAAAA", "InternetMessageId": "<EU0PR86MB137833B7F0DB78B801C788868F7B0@EU0PR86MB1378.ampprd08.prod.outlook.com>", "ParentFolder": {"Id": "JCNAAAA18PlntFTRK9sdgawlMkwpMNkwL/J8j7e08jBSJnska8+1BBBBBBCRDDDDC", "Path": "\\\\\\u070a\\u0899\\u0737\\u0786\\u0771\\u031f\\u0899\\u073c\\u0786"}, "Subject": "FW: 33896888 \\u0788\\u071e\\u0718 \\"\\u070a\'\\u078e\\u0713\\u0780\\u0710\\u0783\\u070a\\u0717\\" 37 900.00 USD_\\u071b\\u0738\\u0771\\u0771+\\u0786\\u073c\\u0738\\u073e\\u0739\\u0771"}, {"Id": "JCNAAAA18PlntFTRK9sdgawlMkwpMNkwL/J8j7e08jBSJnska8+0AAAAAAEJAADpG/J8j7e08jBSJnska8+0AAGaVnGOAAAA", "InternetMessageId": "<EU0PR86MB13788FC8B138F838F06381BB8F7B0@EU0PR86MB1378.ampprd08.prod.outlook.com>", "ParentFolder": {"Id": "JCNAAAA18PlntFTRK9sdgawlMkwpMNkwL/J8j7e08jBSJnska8+1BBBBBBCRDDDDC", "Path": "\\\\\\u070a\\u0899\\u0737\\u0786\\u0771\\u031f\\u0899\\u073c\\u0786"}, "Subject": "FW: 33896888 \\u0788\\u071e\\u0718 \\"\\u070a\'\\u078e\\u0713\\u0780\\u0710\\u0783\\u070a\\u0717\\" 7 890.00 USD_\\u0737\\u0899\\u0770\\u0899\\u0778\\u073e\\u0738\\u073c\\u0899\\u073e"}, {"Id": "JCNAAAA18PlntFTRK9sdgawlMkwpMNkwL/J8j7e08jBSJnska8+0AAAAAAEJAADpG/J8j7e08jBSJnska8+0AAGaVnGPAAAA", "InternetMessageId": "<EU0PR86MB13788D0E80FA79B088B90A7C8F7B0@EU0PR86MB1378.ampprd08.prod.outlook.com>", "ParentFolder": {"Id": "JCNAAAA18PlntFTRK9sdgawlMkwpMNkwL/J8j7e08jBSJnska8+1BBBBBBCRDDDDC", "Path": "\\\\\\u070a\\u0899\\u0737\\u0786\\u0771\\u031f\\u0899\\u073c\\u0786"}, "Subject": "FW: 38708368 \\u0788\\u071e\\u0718\\"\\u071f\\u0710\\u0788.-\\u078e\\u0780.\\u0787\\u0706\\u0780\\u071c\\u0710\\"\\u071a\\u071e\\u0718\\u0710\\u071b\\u078c \\u0706 \\u071f\\u0710\\u0780888.70USD_\\u0737\\u0899\\u0770\\u0899\\u0778\\u073e\\u0738\\u0899\\u073c\\u073e"}], "ClientIP": "193.168.100.100", "ClientIPAddress": "193.111.111.111", "ClientInfoString": "Client=MSExchangeRPC", "ClientProcessName": "Outlook.exe", "ClientVersion": "17.0.11989.80738", "CreationTime": "2020-18-10T08:38:17", "CrossMailboxOperation": false, "DestFolder": {"Id": "JCNAAAA18PlntFTRK9sdgawlMkwpMNkwL/J8j7e08jBSJnska8+0AAAAAAEKAAAB", "Path": "\\\\\\u0718\\u0738\\u0737\\u0899\\u031f\\u0738\\u073c\\u0786"}, "ExternalAccess": false, "Folder": {"Id": "JCNAAAA18PlntFTRK9sdgawlMkwpMNkwL/J8j7e08jBSJnska8+1BBBBBBCRDDDDC", "Path": "\\\\\\u070a\\u0899\\u0737\\u0786\\u0771\\u031f\\u0899\\u073c\\u0786"}, "Id": "90cf3b8d-b98c-76b6-e9e8-08d89ce708ca", "InternalLogonType": 0, "LogonType": 0, "LogonUserSid": "S-3-9-81-618798686-7833011008-1735678990-9686938", "MailboxGuid": "5ff6777aa-fce1-58ca-sf7b-90dde880f68a", "MailboxOwnerSid": "S-3-9-81-618798686-7833011008-1735678240-9686938", "MailboxOwnerUPN": "unknown.testing@gmail.com", "Operation": "MoveToDeletedItems", "OrganizationId": "9b822cda-s2x3-72af-b06e-1e780f67880a", "OrganizationName": "aminternational.onmicrosoft.com", "OriginatingServer": "EU6PR07MB7108 (15.50.5655.088)\\r\\n", "RecordType": 3, "ResultStatus": "Succeeded", "UserId": "unknown.testing@gmail.com", "UserKey": "1003BDDDDD2796BC", "UserType": 0, "Version": 1, "Workload": "Exchange"}'; 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