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

/
/
gxm

Test String

Substitution

Processing...

Code Generator

Generated Code

$re = '/(\${2}[A-Z]{4}, #Callsign \d+, #line number \d{2}:\d{2}:\d{2}, #time (hh:mm:ss) -?\d+\.\d+, #latitude -?\d+\.\d+, #longitude \d{5}, #altitude \d+, #a \d+, #b \d+, #c [\d.]+, #d [\d.]+, #e \d{3}\*[0-9A-Z]{4}) #checksum |(^.*$\R*)/xm'; $str = '$$CALL,1659,14:13:24,40.84870,-113.69349,07916,107,58,12,32.9,4.1,175*C3F1 $$CALL,1660,14:13:26,40.84898,-113.69292,07929,100,58,12,32.9,4.1,175*54DC $$CALL,1661,14:13:29,40.84939,-113.69206,07950,111,57,12,32.9,4.1,175*DDB6 $$CALL,1662,14:13:32,40.84982,-113.69109,07969,111,62,12,32.9,4.1,175*1E13 $$CALL,1663,14:13:3,07985,105,74,12,32.9,4.1,175*A9EF $$CALL,1664,14:13:37,40.85025,-113.68941,07995,105,68,12,32.9,4.1,175*11F1 $$CALL,1665,14:13:40,40.85052,-113.68848,08012,91,76,12,32.9,4.1,175*3B4E $$CALL,1666,14:13:43,40.85069,-113.68761,08030,81,72,12,32.9,4.1,175*3602 $$CALL,1667,14:13:46,40.85096,-113.68690,08052,83,58,12,32.9,4.1,175*A4FA $$CALL,1668,14:13:48,40.85120,-113.68639,08067,102,53,12,32.8,4.1,175*6800 $$CALL,1669,14:13:51,40.85166,-113.68555,08082,109,56,12,32.8,4.1,175*C94E $$CALL,1670,14:13:54,40.85206,-113.68465,08100,104,61,12,32.8,4.1,175*C711 $$CALL,1671,14:13:56,40.85232,-113.68404,08113,102,63,7,32.8,4.1,175*8E14 $$CALL,1672,14:13:59,40.85268,-113.68312,08137,72,54,12,32.8,4.1,175*F764 $$CALL,1673,14:14:02,40.85302,-113.68250,08153,81,54,12,32.8,4.1,175*7EB7 $$CALL,1674,14:14:05,40.85335,-113.68174,08173,89,68,12,32.868117,08183,98,73,12,32.8,4.1,175*3AF2 $$CALL,1676,14:14:10,40.85373,-113.68022,08201,113,63,12,32.8,4.1,175*63EF $$CALL,1677,14:14:13,40.85410,-167922,08215,109,64,12,32.8,4.1,175*7E0D $$CALL,1678,14:14:16,40.85447,-113.67825,08234,107,60,12,32.8,4.1,175*7BDB $$CALL,1679,14:14:18,40.85475,-113.67764,08250,109,63,12,32.8,4.1,175*1F6C $$CALL,1680,14:14:21,40.85508,-113.67664,08267,100,73,12,32.8,4.1,175*8BB9 $$CALL,1681,14:14:24,40.85531,-113.67574,08284,89,66,12,32.7,4.1,175*0A7C $$CALL,1682,14:14:27,40.85557,-113.67497,08299,81,66,12,32.7,4.1,175*138C $$CALL,16835575,-113.67449,08311,85,55,12,32.7,4.1,175*AE98 $$CALL,1684,14:14:32,40.85613,-113.67379,08331,85,54,12,32.7,4.1,175*45B3 $$CALL,1685,14:14:35,40.808354,81,66,12,32.714:14:38,40.85667,-113.67230,08369,85,70,12,32.7,4.1,175*D7F9 $$CALL,1687,14:14:40,40.85684,-113.67173,08378,100,67,12,32.6,4.1,175*CC36 &,1688,14:14:43,40.85712,-113.67080,08397,100,67,12,32.6,4.1,175*D678 $$CALL,1689,14:14:46,40.85740,-113.66988,06,4.1,175*787C $$CALL,1690,14:14:48,40.85758,-113.66923,08425,111,66,12,32.6,4.1,175*5F8E $$CALL,1691,66824,08444,113,61,12,32.6,4.1,175*D33A $$CALL,1692,14:14:54,40.85836,-113.66721,08460,115,58,12,32.6,4.1,175*9867 $$CALL,1693,14:14:57,40.85880,-113.66629,08484,100,57,12,32.6,4.1,175*2A74 $$CALL,1694,14:15:00,40.85916,-113.66546,08510,92,61,12,32.6,12,32.6,4.1,175*7F6$$CALL,1696,14:15:05,40.85997,-113.66428,08542,1 15,55,12,32.6,4.1,175*DBA2 $$CALL,1697,14:15:08,40.86042,-113.66332,08567,104,61,12,32.6,4.1,175*392B $$CA14:15:13,40.86094,-113.66180,08595,126,58,12,32.6,4.1,175*ABC7 $$CALL,1700,14:15:16,40.86145,-113.66080,08609,107,54,190,-113.65989,08628,113,61,12,32.5,4.1,175*D97E'; $subst = "$1"; $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