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

Substitution

Processing...

Code Generator

Generated Code

$re = '/^(.*->)( *(-)?\d*(\.)?\d*: (\'\d{1,}\'))*$/m'; $str = '2022-01-11 09:52:35.65 -> TimingLog -> 1: \'69\' -2: \'434\' -3: \'434\' -4: \'434\' -5: \'509\' -6: \'509\' -6.1: \'509\' -7: \'588\' -19: \'588\' -20: \'588\' -21: \'5145\' -22: \'5202\' -23: \'5224\' -24: \'5233\' -25: \'5233\' 2022-01-11 09:52:48.82 -> TimingLog -> 1: \'47\' -2: \'213\' -3: \'213\' -4: \'213\' -5: \'269\' -6: \'269\' -6.1: \'269\' -7: \'298\' -8: \'298\' -12: \'380\' -13: \'380\' -14: \'6270\' -15: \'6328\' -16: \'6347\' -17: \'6356\' -18: \'6356\' 2022-01-11 09:53:02.68 -> TimingLog -> 1: \'23\' -2: \'54\' -3: \'54\' -4: \'54\' -5: \'65\' -6: \'65\' -6.1: \'65\' -7: \'76\' -19: \'76\' -20: \'76\' -21: \'4916\' -22: \'4982\' -23: \'5010\' -24: \'5015\' -25: \'5015\' 2022-01-11 09:53:06.57 -> HandleArticleWarningOnOrder -> -1: \'160\' -2: \'223\' -1: \'223\' -2: \'285\' -1: \'285\' -2: \'671\' -1: \'671\' -2: \'816\' -1: \'816\' -2: \'970\' -1: \'970\' -2: \'1122\' -3: \'1122\' -4: \'1312\' -5: \'17766\' -6: \'17766\' 2022-01-11 09:53:17.01 -> TimingLog -> 1: \'140\' -2: \'527\' -3: \'527\' -4: \'527\' -5: \'671\' -6: \'671\' -6.1: \'671\' -7: \'737\' -19: \'737\' -20: \'737\' -21: \'5984\' -22: \'6163\' -23: \'6307\' -24: \'6339\' -25: \'6339\' 2022-01-11 09:53:25.12 -> TimingLog -> 1: \'25\' -2: \'85\' -3: \'85\' -4: \'85\' -5: \'108\' -6: \'108\' -6.1: \'108\' -7: \'117\' -19: \'117\' -20: \'117\' -21: \'7706\' -22: \'7880\' -23: \'8018\' -24: \'8110\' -25: \'8110\' 2022-01-11 09:53:31.90 -> TimingLog -> 1: \'51\' -2: \'210\' -3: \'210\' -4: \'210\' -5: \'269\' -6: \'269\' -6.1: \'269\' -7: \'324\' -19: \'324\' -20: \'324\' -21: \'6641\' -22: \'6675\' -23: \'6704\' -24: \'6711\' -25: \'6711\' 2022-01-11 09:53:44.04 -> TimingLog -> 1: \'27\' -2: \'121\' -3: \'121\' -4: \'121\' -5: \'202\' -6: \'202\' -6.1: \'202\' -7: \'215\' -19: \'215\' -20: \'215\' -21: \'6520\' -22: \'6566\' -23: \'6594\' -24: \'6604\' -25: \'6604\' 2022-01-11 09:53:53.51 -> TimingLog -> 1: \'72\' -2: \'275\' -3: \'275\' -4: \'275\' -5: \'302\' -6: \'302\' -6.1: \'302\' -7: \'327\' -8: \'327\' -12: \'413\' -13: \'413\' -14: \'7408\' -15: \'7571\' -16: \'7725\' -17: \'7731\' -18: \'7731\' 2022-01-11 09:54:04.27 -> TimingLog -> 1: \'22\' -2: \'72\' -3: \'72\' -4: \'72\' -5: \'86\' -6: \'86\' -6.1: \'86\' -7: \'105\' -8: \'105\' -12: \'147\' -13: \'147\' -14: \'5192\' -15: \'5223\' -16: \'5251\' -17: \'5269\' -18: \'5269\' 2022-01-11 09:54:09.16 -> HandleArticleWarningOnOrder -> -1: \'91\' -2: \'188\' -2.1: \'188\' -3: \'188\' -4: \'351\' -5: \'18276\' -6: \'18276\' 2022-01-11 09:54:12.80 -> TimingLog -> 1: \'13\' -2: \'43\' -3: \'43\' -4: \'43\' -5: \'51\' -6: \'51\' -6.1: \'51\' -7: \'57\' -8: \'57\' -12: \'86\' -13: \'86\' -14: \'8024\' -15: \'8263\' -16: \'8430\' -17: \'8524\' -18: \'8524\' 2022-01-11 09:54:21.30 -> TimingLog -> 1: \'105\' -2: \'353\' -3: \'353\' -4: \'353\' -5: \'414\' -6: \'414\' -6.1: \'414\' -7: \'470\' -8: \'470\' -12: \'814\' -13: \'814\' -14: \'8172\' -15: \'8336\' -16: \'8449\' -17: \'8480\' -18: \'8480\' 2022-01-11 09:54:34.02 -> HandleArticleWarningOnOrder -> -1: \'102\' -2: \'154\' -2.1: \'154\' -3: \'154\' -4: \'202\' -5: \'20106\' -6: \'20106\' ...'; $subst = "$1$5"; $result = preg_replace($re, $subst, $str); echo "The result of the substitution is ".$result;

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