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
  • 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
No Match

/
/
gm

Test String

Substitution

Processing...

Code Generator

Generated Code

const regex = /<\/p><p>.*>(.+?)<.*[:-] (.*)/gm; // Alternative syntax using RegExp constructor // const regex = new RegExp('<\\\/p><p>.*>(.+?)<.*[:-] (.*)', 'gm') const str = `</p><p><b><a href="/index.php/AGS" title="AGS">AGS</a></b>: Amazon Global Store </p><p><b><a href="/index.php?title=APPH&amp;action=edit&amp;redlink=1" class="new" title="APPH (page does not exist)">APPH</a></b>: Actual Pick Rate </p><p><b>APV</b>: Amazon Prime Video </p><p><b><a href="/index.php?title=ASK_ID&amp;action=edit&amp;redlink=1" class="new" title="ASK ID (page does not exist)">ASK ID</a></b>: Alexa Skills Kit International Data </p><p><b><a href="/index.php/AWS" title="AWS">AWS</a></b>: Advertiser Web Services </p><p><b><a href="/index.php/CBP" title="CBP">CBP</a></b>: Cross Border Pricing </p><p><b><a href="/index.php/CDF" title="CDF">CDF</a></b>: Cumulative Distribution Function </p><p><b><a href="/index.php?title=CVSD&amp;action=edit&amp;redlink=1" class="new" title="CVSD (page does not exist)">CVSD</a></b>: Convenience Store Delivery </p><p><b><a href="/index.php/CWGR" title="CWGR">CWGR</a></b>: Compound Weekly Growth Rate </p><p><b>DEXTER</b>: Delivery Execution Tracking Evaluation and Reconciliation </p><p><b><a href="/index.php?title=DMI&amp;action=edit&amp;redlink=1" class="new" title="DMI (page does not exist)">DMI</a></b>: Desktop Management Interface </p><p><b>DNB</b>: Digital Native Business (AWS) </p><p><b>eCPDPV</b>: effective Cost Per Detail Page View </p><p><b>EOR</b>: Exporter of Record (see also IOR) </p><p><b>FAST</b>: Flexible Accelerated Recruiting Team (Consumer Talent) </p><p><b>FEC</b>: FC execution cluster/system </p><p><a href="https://w.amazon.com/index.php/TranslationTeam" class="external text" rel="nofollow"><b>FL</b></a>: Freelance Translation Specialist </p><p><b><a href="/index.php?title=FMM&amp;action=edit&amp;redlink=1" class="new" title="FMM (page does not exist)">FMM</a></b>: Field Marketing Manager (AWS) </p><p><b>FQ</b>: Feature Question (ORR) </p><p><b><a href="/index.php/FRA3" title="FRA3">FRA3</a></b>: Second FC, Bad Hersfeld </p><p><b>FRT</b>: First Response Time </p><p><b>FSSS</b>: Free Super Saver Shipping </p><p><b>G/NG</b>: Go/No Go </p><p><b><a href="/index.php?title=GOE&amp;action=edit&amp;redlink=1" class="new" title="GOE (page does not exist)">GOE</a></b>: Global Optimization Engine </p><p><a href="https://w.amazon.com/index.php/Ingenii" class="external text" rel="nofollow"><b>INGENII</b></a>: Amazon's Career's growth plan tool </p><p><b>IN</b>: India Marketplace </p><p><b><a href="/index.php/Ion" title="Ion">ION</a></b>: Inter-operable Object Notation </p><p><b>IOR</b>: Importer of Record (see also EOR) </p><p><b><a href="/index.php?title=LCPO&amp;action=edit&amp;redlink=1" class="new" title="LCPO (page does not exist)">LCPO</a></b>: Low Confidence Purchase Order </p><p><b>LRR</b>: Launch Readiness Review </p><p><b><a href="/index.php?title=MQL&amp;action=edit&amp;redlink=1" class="new" title="MQL (page does not exist)">MQL</a></b>: Marketing Qualified Lead (AWS) </p><p><b><a href="/index.php/MUC3" title="MUC3">MUC3</a></b>: FC, Graben </p><p><b>OLVCS</b>: Offer Level VAT Calculation Services </p><p><b><a href="/index.php?title=P2S&amp;action=edit&amp;redlink=1" class="new" title="P2S (page does not exist)">P2S</a></b>: Propensity to Spend (AWS) </p><p><a href="https://w.amazon.com/index.php/B2B/ProfessionalLicensing" class="external text" rel="nofollow"><b>PLP</b></a>: Professional Licensing Program </p><p><b><a href="/index.php/RAP" title="RAP">RAP</a></b>: Recruiter Academy Program (Consumer Talent) </p><p><b><a href="/index.php/RHEL" title="RHEL">RHEL</a></b>: Red Hat Enterprise Linux </p><p><b><a href="/index.php/RFV" title="RFV">RFV</a></b>: Resolving For Visibility </p><p><b><a href="/index.php/RHMD" title="RHMD">RHMD</a></b>: Recruiter How's My Driving </p><p><b><a href="/index.php/SLCS" title="SLCS">SLCS</a></b>: <a href="/index.php/SourcingLandedCostService" title="SourcingLandedCostService">Sourcing Landed Cost Service</a> (See also <b><a href="/index.php/LandedCost" title="LandedCost">Landed Cost</a></b>) </p><p><b><a href="/index.php/SRL" title="SRL">SRL</a></b>: Start Reading Location, a feature on Kindle that opens ebooks to the title page, for KiM titles it's set to the cover page so the customer can view the illustrated motion </p><p><b><a href="/index.php/SSX" title="SSX">SSX</a></b>: Shared Shopping Experience </p><p><b><a href="/index.php/SQL" title="SQL">SQL</a></b>: Sales Qualified Lead (AWS) </p><p><b><a href="https://w.amazon.com/index.php/TranslationTeam" class="external text" rel="nofollow">TS</a></b>: Translation Specialist </p><p><b><a href="/index.php/VAS" title="VAS" class="mw-redirect">VAS</a></b>: Value Added Services <b><a href="https://w.amazon.com/bin/view/ValueAddedServices/Glossary/" class="external text" rel="nofollow">(VAS Specific Acronyms)</a></b> </p><p><b><a href="/index.php/VF" title="VF">VF</a></b>: Vinnige Fanie`; const subst = `$1 - $2`; // The substituted value will be contained in the result variable const result = str.replace(regex, subst); console.log('Substitution result: ', 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 JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions