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
  • Match everything enclosed
    (?:...)
  • Capture everything enclosed
    (...)
  • 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 = '/Xpra(?<vcxXPRA>\s\d{1,2}\/\d{1,2}\/\d{1,2})\sF:(?<vcxXPRAfreqname>\w{1,9})\s(?<vcxXPRAfreq>\d{3},\d{3})\sTx\((?<vcxXPRAtxPTT>\d\d\d\d)\s(?<vcxXPRAtxPTTmin>\d{2,4}):(?<vcxXPRAtxPTTsec>\d{2,4})\)\sRx\((?<vcxXPRArxSQ>\d\d\d\d)\s(?<vcxXPRArxSQmin>\d{2,4}):(?<vcxXPRArxSQsec>\d{2,4})\);$/m'; $str = 'VCX_Stat;31.07.2018 20:43:59;S;ATCC#3 V 3 0 VCX - SVS ACC Phone/vieint1044(1):366001-&gt371701 Voc TRM:nrm.cl.clr T:0:19 CL: 42 PL: 42 CI: 0 CPT:4; VCX_Stat;14.10.2018 23:40:13;S;INN#3 V 3 0 \'inn2pat_1003\' (4) Total: 0:29; VCX_Stat;14.10.2018 23:39:57;S;ATCC#1 V 1 0 Xpra 8/1/1 F:MIL3 139,100 Tx(0000 00:00) Rx(0001 00:04); VCX_Stat;14.10.2018 23:38:47;S;ATCC#2 V 2 0 VIE BRA/bravie0501:362999-&gt999999 Voc REJ:unall.num. T:0:00 CL: 44 PL: 44 CI: 0 CPT:4; VCX_Stat;14.10.2018 23:38:35;S;ATCC#1 V 1 0 VCX - SVS ACCFuKOR_/vieint1049(2):676135-&gt661635 Voc TRM:nrm.cl.clr T:0:09 CL: 8 PL: 8 CI: 0 CPT:3; VCX_Stat;14.10.2018 23:38:35;S;ATCC#1 V 1 0 INN - VIE__2MBit__/innvie1201(3):676135-&gt661635 Voc TRM:nrm.cl.clr T:0:09 CL: 8 PL: 8 CI: 0 CPT:3; VCX_Stat;14.10.2018 23:38:35;S;INN#3 V 3 0 INN2 - VOR_________/inn2vor_1005(2):676135-&gt661635 Voc TRM:nrm.cl.clr T:0:09 CL: 8 PL: 8 CI: 0 CPT:3; VCX_Stat;14.10.2018 23:38:35;S;INN#3 V 3 0 INN - VIE__2MBit__/innvie1201(3):676135-&gt661635 Voc TRM:nrm.cl.clr T:0:09 CL: 8 PL: 8 CI: 0 CPT:3; VCX_Stat;14.10.2018 23:38:23;S;INN#3 V 3 0 INN - VIE__2MBit__/innvie1201(3):676134-&gt661634 Voc TRM:nrm.cl.clr T:0:09 CL: 8 PL: 8 CI: 0 CPT:3; VCX_Stat;14.10.2018 23:38:23;S;ATCC#1 V 1 0 /Qsig2M 4/1/2(28):676134-&gt661634 Voc TRM:nrm.cl.clr T:0:09 CL: 8 PL: 8 CI: 0 CPT:3; VCX_Stat;14.10.2018 23:38:23;S;ATCC#3 V 3 0 /Qsig2M 4/1/1(28):676134-&gt661634 Voc TRM:nrm.cl.clr T:0:09 CL: 8 PL: 8 CI: 0 CPT:3; VCX_Stat;14.10.2018 23:38:23;S;ATCC#1 V 1 0 INN - VIE__2MBit__/innvie1201(3):676134-&gt661634 Voc TRM:nrm.cl.clr T:0:09 CL: 8 PL: 8 CI: 0 CPT:3;'; 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