Regular Expressions 101

Save & Share

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

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 = '/^(?P<UserID>\w*)\|(?P<UserType>\w*)\|(?P<System>\w*)\|(?P<EventType>\w*)\|(?P<EventId>[^\|]*)\|(?P<Subject>[^\|]*)\|(?P<SID>[^\|]*)\|(?P<IPAddr>[^\|]*)\|(?P<EventStatus>[^\|]*)\|(?P<Msg>[^\|]*)\|(?P<TimeStamp>[^\|]*)\|(?P<DATA>[^\|]*)\|(?P<Period>[^\|]*)\|(?P<MCode>[^\|]*)\|(?P<Type>[^\|]*)\|(?P<Type2>[^\|]*)\|(?P<DeviceId>[^\|]*)\|(?P<DesIP>[^\|]*)\|(?P<Code>[^\|]*)\|(?P<Headers>.*)/m'; $str = 'TESTUser|TESTSYSTEM|DNSTEST|USERTEST|CREATE_SUPER_USER_GROUP|TEST_ELEMENT<GROUP_NAME_group3>|19e4e88e-7fb1-4309-b8a3-93180e41ef86|76.253.69.172|00||2022-04-14T23:59:33.059-0400|{dsUrn: testgroup:\'da04c367-b41c-421a-85e1-d5ab759c0c82\'}|NA|||||10.207.92.23|23| TESTUser|TESTSYSTEM|DNSTEST|USER|VIS_EXPORT_EXCEL|TEST_ELEMENT<DNSTES_801482320>|ce01fdc2-2bbe-45ef-845b-f79576e215bf|65.144.148.136|00||2022-05-09T10:21:44.021-0400|{dsUrn: testgroup:\'6f10e8f8-100b-4482-9b09-10e18504924c\'}|NA|||||10.207.92.23|23|23as TESTUser|TESTSYSTEM|DNSTEST|USERTEST|IMPERSONATE_USER|TEST_ELEMENT<USERNAME_TESTUser4>|c594626f-e6e9-4abd-9e0b-fa9861c47285|236.214.26.15|00||2022-05-10T07:52:48.052-0400|{dsUrn: testgroup:\'DNS -3ac6-4e92-b50b-e903961f5894\'}|NA|||||10.207.92.23|23| TESTUser1TESTUser|TESTSYSTEM|DNSTEST|USER|VIS_SAVE|TEST_ELEMENT<UNVERIFIED_648656466>|5143518f-dc60-433b-a0cc-2fa024b25360|241.254.244.33|00||2022-05-02T05:01:58.001-0400|{dsUrn: testgroup:\'157c4534-d970-4b7b-9181-1bddb8f7a670\'}|NA|||||10.207.92.23|23| |TESTSYSTEM|DNSTEST|USERTEST|ENABLE_USER|TEST_ELEMENT<USERNAME_TESTUser1>|2923b00c-0a95-465d-85aa-3af5387e992c|19.173.21.53|00||2022-05-29T12:13:26.013-0400|{dsUrn: \'DNS\', groupId:\'49de37d5-ea28-45ba-be52-84d933425636\'}|NA|||||10.207.92.23|23| TESTUser6|TESTSYSTEM|DNSTEST|USERTEST|ENABLE_USER|TEST_ELEMENT<USERNAME_TESTUser5>|0f1ba654-03bf-DNS-ac8f-8f5185232d42|245.236.181.176|00||2022-04-09T02:14:23.014-0400|{dsUrn: testgroup:\'b6a89e91-ac03-4641-a3bc-166d013df252\'}|NA|||||10.207.92.23|23| TESTUser2|TESTSYSTEM|DNSTEST|USERTEST|UPDATE_TESTDATA|TEST_ELEMENT<USERNAME_TESTUser>|0acf2593-d7ee-4ba8-bf4e-29a4d4adcdaf|213.184.95.84|01|Failed to update TESTDATA. TESTDATA.|2022-03-12T08:03:19.003-0500|{dsUrn: \'gp\', groupId:\'9850940e-ff7b-4b77-820b-8d0472933c4a\'}|NA|||||10.207.92.23|500|2w1 TESTUser|TESTSYSTEM|DNSTEST|USERTEST|CREATE_SUPER_USER_GROUP|TEST_ELEMENT<GROUP_NAME_group3>|9717a152-3809-416a-87a3-e9a4bc9b01a9|14.22.163.187|00||2022-03-19T10:34:35.034-0400|{dsUrn: \'DNSTEST\', groupId:\'cf9263ba-aff7-4e34-98c1-a09d17aaf8d6\'}|NA|||||10.207.92.23|23|header12'; 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