Regular Expressions 101

Save & Manage Regex

  • Current Version: 1
  • Save & Share
  • 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
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 = '/\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\] <(\S+)>/'; $str = '[2016-04-19 15:22:04] <saxjax> [PT_] Intel HEX [2016-04-19 15:22:26] <saxjax> [Cemetech] T.Wang entered the room [2016-04-19 15:23:03] <saxjax> [Cemetech] Vital7788 entered the room [2016-04-19 15:23:30] <saxjax> [Cemetech] tfeverston entered the room [2016-04-19 15:23:42] <saxjax> [Cemetech] mr womp womp entered the room [2016-04-19 15:24:07] — nikky licks KermPhD [2016-04-19 15:25:11] <saxjax> [mr womp womp] same xD [2016-04-19 15:25:17] <nikky> KermPhD: http://www.ebay.com/itm/Amtrak-Diesel-Railroad-Hat-Pin-RR-Train-Railway-/161962057280 [2016-04-19 15:26:14] <saxjax> [Cemetech] Botboy3000 entered the room [2016-04-19 15:26:21] <saxjax> [Cemetech] Carthago entered the room [2016-04-19 15:26:22] ⇐ sigtrm quit (quassel@quassel.woboq.de): Ping timeout: 260 seconds [2016-04-19 15:28:57] → sigtrm joined (quassel@quassel.woboq.de) [2016-04-19 15:30:58] <KermPhD> nikky++ that\'s pretty cool [2016-04-19 15:32:10] <saxjax> [PT_] @z80 800F00000FA88012010480210180310180484178652020202020808101809003 [2016-04-19 15:32:10] <RunerBot_> [Z80] Disassembly | http://www.rafb.me/results/9u9cE879.html | 32 bytes [2016-04-19 15:32:26] <saxjax> [PT_] hmmmm [2016-04-19 15:33:06] <saxjax> [PT_] Is there anywhere a Intel HEX disassembler? [2016-04-19 15:33:32] <saxjax> [PT_] @z80 260904046F1B80020D40A16B99F659BC67F5859C096C0FB4039BC903322CE003 [2016-04-19 15:33:32] <RunerBot_> [Z80] Disassembly | http://www.rafb.me/results/jZ2qCG16.html | 32 bytes [2016-04-19 15:33:50] <saxjax> [Cemetech] Johnfrank registered and activated a new account [2016-04-19 15:34:00] <saxjax> [Cemetech] Johnfrank entered the room [2016-04-19 15:34:00] <Cemetech> Johnfrank, welcome to Cemetech! Please introduce yourself in this topic: http://cemete.ch/t4925 [2016-04-19 15:34:17] <debrouxl> PT_: you\'re disassembling data... [2016-04-19 15:34:26] <debrouxl> What you posted here is the FlashApp header. [2016-04-19 15:34:34] <debrouxl> In the well-known TI certificate format. [2016-04-19 15:34:42] <saxjax> [PT_] oh dear [2016-04-19 15:34:48] <saxjax> [PT_] Whatever I do, I\'m wrong XD [2016-04-19 15:35:33] <saxjax> [PT_] @z80 45004552523A20424C4F434B004552523A2048455849444543494D414C004552 [2016-04-19 15:35:34] <RunerBot_> [Z80] Disassembly | http://www.rafb.me/results/FcaFVU43.html | 32 bytes [2016-04-19 15:35:41] <saxjax> [PT_] This shouldn\'t be the certificate I hope [2016-04-19 15:35:49] <saxjax> [PT_] nvm :( [2016-04-19 15:36:04] <debrouxl> 800(F) is the 8000 field, size indication F, so followed by 4 bytes containing the 32-bit field size as big-endian. [2016-04-19 15:36:27] <saxjax> [PT_] I\'m only trying to disassemble an app :| [2016-04-19 15:37:07] <debrouxl> 0326 0904 xxxxxxxx is the timestamp field, xxxxxxxx is the number of seconds since January 1st 1997, 00:00:00 in some timezone, as big endian. [2016-04-19 15:37:38] <saxjax> [Cemetech] Johnfrank created a new topic [Ti-82 Stats Hiding programs]( http://cemete.ch/p248225 ) [2016-04-19 15:37:39] <debrouxl> 02 0D 40 <64 bytes> is the signature field corresponding to the timestamp. [2016-04-19 15:38:30] <saxjax> [PT_] dang [2016-04-19 15:39:46] <debrouxl> The 512-bit RSA key for validating timestamps was among the set of 13 keys we factored in 2009, triggering TI\'s misplaced wrath and completely illegal attacks on people who were doing legal stuff ("TI signing key controversy"). [2016-04-19 15:39:47] <KermPhD> Amtrak deaths per 100 million passenger miles: 0.03 deaths [2016-04-19 15:39:58] <KermPhD> Automobile deaths per 100 million passenger miles: 0.48 deaths [2016-04-19 15:40:04] <KermPhD> (ie, 12 times more dangerous) [2016-04-19 15:40:11] <KermPhD> *16 times more dangerous. math. [2016-04-19 15:40:27] <saxjax> [Cemetech] dicamarques entered the room [2016-04-19 15:40:31] <debrouxl> Yup. [2016-04-19 15:41:03] <debrouxl> PT_: you just have to skip to the field containing the actual assembly code ;) [2016-04-19 15:41:03] <saxjax> [Cemetech] elfprince13 added a post in [Self-Defined Object Language & Computer System]( http://cemete.ch/p248226 ) [2016-04-19 15:41:38] <saxjax> [PT_] And where does that start? At which address? :O [2016-04-19 15:41:44] <saxjax> [PT_] Sorry, I\'m reallyl dumb [2016-04-19 15:42:36] <debrouxl> Modern libtifiles (from Git) even contains functions for parsing data in TI certificate format. [2016-04-19 15:42:40] <saxjax> [PT_] @z80 ED73EC86FDCB1486FDCB14FEFDCB3CC6FDCB0D8EEF7045AF32EE8632EF862100 [2016-04-19 15:42:41] <RunerBot_> [Z80] Disassembly | http://www.rafb.me/results/oEqc9p39.html | 32 bytes [2016-04-19 15:43:06] <saxjax> [PT_] That seems more like assembly code [2016-04-19 15:43:07] <debrouxl> "FDCB" looks like proper (e)Z80. [2016-04-19 15:43:31] <saxjax> [PT_] @z80 00224B84EF4045FDCB05DE21E24ECD2D49FDCB059E2A3098CD5F46B720523AEF [2016-04-19 15:43:32] <RunerBot_> [Z80] Disassembly | http://www.rafb.me/results/K7sEt899.html | 32 bytes [2016-04-19 15:43:56] <saxjax> [PT_] That seems better XD [2016-04-19 15:44:00] <Mateo> I mean, it\'s not like there are tools to disassemble an app or anything [2016-04-19 15:44:03] — Mateo hides [2016-04-19 15:44:12] <saxjax> [PT_] Last try:\' [2016-04-19 15:44:16] <saxjax> [PT_] @z80 86B7280647CD814610FBE5210100224B844CE13AEE86B93E202006FDCB05DE3E [2016-04-19 15:44:16] <RunerBot_> [Z80] Disassembly | http://www.rafb.me/results/Ly5qjz42.html | 32 bytes [2016-04-19 15:44:30] — Mateo continues to point to app disassembly tools [2016-04-19 15:44:37] <saxjax> [PT_] Yep [2016-04-19 15:44:38] <KermPhD> IDA Pro! [2016-04-19 15:44:41] <Mateo> Woo [2016-04-19 15:44:46] <Mateo> It\'s pretty nice [2016-04-19 15:44:46] <saxjax> [PT_] Are all the apps formatted in Intel HEX format? [2016-04-19 15:44:55] <Mateo> ? [2016-04-19 15:44:58] <Mateo> Wat [2016-04-19 15:45:06] <saxjax> *PT_ flies away [2016-04-19 15:45:10] <Mateo> None are formatted in Intel HEX [2016-04-19 15:45:16] <saxjax> [PT_] :| [2016-04-19 15:45:29] <saxjax> [PT_] Kerm just said that :/ [2016-04-19 15:45:44] <Mateo> Kerm, why? :) [2016-04-19 15:46:00] — Mateo is joking [2016-04-19 15:46:12] <saxjax> [PT_] fk u :O [2016-04-19 15:46:22] <saxjax> [PT_] I just wanna learn ASM [2016-04-19 15:46:51] <saxjax> [PT_] Anyway, going to bed. See ya later! [2016-04-19 15:47:15] <Mateo> Goodnight! [2016-04-19 15:48:13] <Mateo> Oh, I see [2016-04-19 15:49:04] <saxjax> [mr womp womp] bye PT_ [2016-04-19 15:49:30] <saxjax> [Cemetech] comicIDIOT entered the room [2016-04-19 15:56:05] <KermPhD> Good night, PT_! [2016-04-19 15:58:08] <saxjax> [Cemetech] shaina registered and activated a new account [2016-04-19 15:59:02] <saxjax> [Cemetech] shaina entered the room [2016-04-19 15:59:02] <Cemetech> shaina, welcome to Cemetech! Please introduce yourself in this topic: http://cemete.ch/t4925 [2016-04-19 16:04:07] <saxjax> [Cemetech] mr womp womp added a post in [Introduce Yourself!]( http://cemete.ch/p248227 ) [2016-04-19 16:05:04] <saxjax> [Cemetech] awesommee333 entered the room [2016-04-19 16:06:46] <saxjax> [Cemetech] Comments2010 entered the room [2016-04-19 16:07:44] <saxjax> [Comments2010] Typo in Terms of Service for Cemetech, "sdeemed" in paragraph 2, sentence 3. [2016-04-19 16:07:54] <saxjax> [Cemetech] Michael2_3B entered the room'; 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