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 = '/\{\{*CreateDate*\}\}/m'; $str = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <w:document xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:cx="http://schemas.microsoft.com/office/drawing/2014/chartex" xmlns:cx1="http://schemas.microsoft.com/office/drawing/2015/9/8/chartex" xmlns:cx2="http://schemas.microsoft.com/office/drawing/2015/10/21/chartex" xmlns:cx3="http://schemas.microsoft.com/office/drawing/2016/5/9/chartex" xmlns:cx4="http://schemas.microsoft.com/office/drawing/2016/5/10/chartex" xmlns:cx5="http://schemas.microsoft.com/office/drawing/2016/5/11/chartex" xmlns:cx6="http://schemas.microsoft.com/office/drawing/2016/5/12/chartex" xmlns:cx7="http://schemas.microsoft.com/office/drawing/2016/5/13/chartex" xmlns:cx8="http://schemas.microsoft.com/office/drawing/2016/5/14/chartex" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:aink="http://schemas.microsoft.com/office/drawing/2016/ink" xmlns:am3d="http://schemas.microsoft.com/office/drawing/2017/model3d" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:oel="http://schemas.microsoft.com/office/2019/extlst" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" xmlns:w16cex="http://schemas.microsoft.com/office/word/2018/wordml/cex" xmlns:w16cid="http://schemas.microsoft.com/office/word/2016/wordml/cid" xmlns:w16="http://schemas.microsoft.com/office/word/2018/wordml" xmlns:w16sdtdh="http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash" xmlns:w16se="http://schemas.microsoft.com/office/word/2015/wordml/symex" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" mc:Ignorable="w14 w15 w16se w16cid w16 w16cex w16sdtdh wp14"> <w:body> <w:p w14:paraId="1599AF6E" w14:textId="34AAE6AB" w:rsidR="00F64201" w:rsidRDefault="00B721B4" w:rsidP="00B721B4"> <w:pPr> <w:pStyle w:val="Heading1"/> </w:pPr> <w:r> <w:t>{{</w:t> </w:r> <w:proofErr w:type="spellStart"/> <w:r> <w:t>Company_Name</w:t> </w:r> <w:proofErr w:type="spellEnd"/> <w:r> <w:t>}} {{APP}} Account Data</w:t> </w:r> </w:p> <w:p w14:paraId="278C6776" w14:textId="1B6000C5" w:rsidR="00B721B4" w:rsidRDefault="00B721B4"/> <w:tbl> <w:tblPr> <w:tblStyle w:val="TableGrid"/> <w:tblW w:w="0" w:type="auto"/> <w:tblLook w:val="04A0" w:firstRow="1" w:lastRow="0" w:firstColumn="1" w:lastColumn="0" w:noHBand="0" w:noVBand="1"/> </w:tblPr> <w:tblGrid> <w:gridCol w:w="1870"/> <w:gridCol w:w="1870"/> <w:gridCol w:w="1870"/> <w:gridCol w:w="1870"/> <w:gridCol w:w="1870"/> </w:tblGrid> <w:tr w:rsidR="00B721B4" w14:paraId="100413BB" w14:textId="77777777" w:rsidTr="00B721B4"> <w:tc> <w:tcPr> <w:tcW w:w="1870" w:type="dxa"/> </w:tcPr> <w:p w14:paraId="5FD7C610" w14:textId="015F6641" w:rsidR="00B721B4" w:rsidRDefault="00B721B4"> <w:r> <w:t>Name</w:t> </w:r> </w:p> </w:tc> <w:tc> <w:tcPr> <w:tcW w:w="1870" w:type="dxa"/> </w:tcPr> <w:p w14:paraId="73D639A3" w14:textId="0258323E" w:rsidR="00B721B4" w:rsidRDefault="00B721B4"> <w:proofErr w:type="spellStart"/> <w:r> <w:t>CreateDate</w:t> </w:r> <w:proofErr w:type="spellEnd"/> </w:p> </w:tc> <w:tc> <w:tcPr> <w:tcW w:w="1870" w:type="dxa"/> </w:tcPr> <w:p w14:paraId="7C6E1CA5" w14:textId="4B5E3085" w:rsidR="00B721B4" w:rsidRDefault="00B721B4"> <w:r> <w:t>VIP</w:t> </w:r> </w:p> </w:tc> <w:tc> <w:tcPr> <w:tcW w:w="1870" w:type="dxa"/> </w:tcPr> <w:p w14:paraId="274DDEA7" w14:textId="516124C5" w:rsidR="00B721B4" w:rsidRDefault="00B721B4"> <w:r> <w:t>Points</w:t> </w:r> </w:p> </w:tc> <w:tc> <w:tcPr> <w:tcW w:w="1870" w:type="dxa"/> </w:tcPr> <w:p w14:paraId="7163781E" w14:textId="460DA08B" w:rsidR="00B721B4" w:rsidRDefault="00B721B4"> <w:r> <w:t>Remark</w:t> </w:r> </w:p> </w:tc> </w:tr> <w:tr w:rsidR="00B721B4" w14:paraId="35A728A6" w14:textId="77777777" w:rsidTr="00B721B4"> <w:tc> <w:tcPr> <w:tcW w:w="1870" w:type="dxa"/> </w:tcPr> <w:p w14:paraId="0775B817" w14:textId="17DA096B" w:rsidR="00B721B4" w:rsidRDefault="00B721B4"> <w:r> <w:t>{{Name}}</w:t> </w:r> </w:p> </w:tc> <w:tc> <w:tcPr> <w:tcW w:w="1870" w:type="dxa"/> </w:tcPr> <w:p w14:paraId="4A2404F3" w14:textId="6CC57F74" w:rsidR="00B721B4" w:rsidRDefault="00B721B4"> <w:r> <w:t>Hello World Company</w:t> </w:r> </w:p> </w:tc> <w:tc> <w:tcPr> <w:tcW w:w="1870" w:type="dxa"/> </w:tcPr> <w:p w14:paraId="62DEB9C3" w14:textId="618125BB" w:rsidR="00B721B4" w:rsidRDefault="00B721B4"> <w:r> <w:t>{{VIP}}</w:t> </w:r> </w:p> </w:tc> <w:tc> <w:tcPr> <w:tcW w:w="1870" w:type="dxa"/> </w:tcPr> <w:p w14:paraId="158965BA" w14:textId="1EA5CD08" w:rsidR="00B721B4" w:rsidRDefault="00B721B4"> <w:r> <w:t>{{Points}}</w:t> </w:r> </w:p> </w:tc> <w:tc> <w:tcPr> <w:tcW w:w="1870" w:type="dxa"/> </w:tcPr> <w:p w14:paraId="53105C06" w14:textId="07109D26" w:rsidR="00B721B4" w:rsidRDefault="00B721B4"> <w:r> <w:t xml:space="preserve">{{Name}} has </w:t> </w:r> <w:r w:rsidRPr="005F3C0A"> <w:rPr> <w:color w:val="FF0000"/> </w:rPr> <w:t xml:space="preserve">{{Points}} </w:t> </w:r> <w:r> <w:t>points</w:t> </w:r> </w:p> </w:tc> </w:tr> </w:tbl> <w:p w14:paraId="671D355C" w14:textId="77777777" w:rsidR="00B721B4" w:rsidRDefault="00B721B4"/> <w:sectPr w:rsidR="00B721B4"> <w:pgSz w:w="12240" w:h="15840"/> <w:pgMar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440" w:header="720" w:footer="720" w:gutter="0"/> <w:cols w:space="720"/> <w:docGrid w:linePitch="360"/> </w:sectPr> </w:body> </w:document>'; 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