Regular Expressions 101

Save & Share

  • Regex Version: ver. 52
  • 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
No Match

/
/
g

Test String

Substitution

Processing...

Code Generator

Generated Code

const regex = /(?<="aspectRatio"\:\s\")\d+:\d+/g; // Alternative syntax using RegExp constructor // const regex = new RegExp('(?<="aspectRatio"\\:\\s\\")\\d+:\\d+', 'g') const str = `{ "timeline": { "background": "#---secondaryColor---", "fonts": [ { "src": "https://perry-template-assets.s3.us-east-2.amazonaws.com/fonts/Arial-Black.ttf" }, { "src": "https://perry-template-assets.s3.us-east-2.amazonaws.com/fonts/Arial-BoldItalicMT.ttf" }, { "src": "https://perry-template-assets.s3.us-east-2.amazonaws.com/fonts/Arial-BoldMT.ttf" }, { "src": "https://perry-template-assets.s3.us-east-2.amazonaws.com/fonts/Arial-ItalicMT.ttf" }, { "src": "https://perry-template-assets.s3.us-east-2.amazonaws.com/fonts/Arial.ttf" }, { "src": "https://perry-template-assets.s3.us-east-2.amazonaws.com/fonts/ArialNarrow-Bold.ttf" }, { "src": "https://perry-template-assets.s3.us-east-2.amazonaws.com/fonts/ArialNarrow-BoldItalic.ttf" }, { "src": "https://perry-template-assets.s3.us-east-2.amazonaws.com/fonts/ArialNarrow-Italic.ttf" }, { "src": "https://perry-template-assets.s3.us-east-2.amazonaws.com/fonts/ArialNarrow.ttf" }, { "src": "https://perry-template-assets.s3.us-east-2.amazonaws.com/fonts/Caveat-Regular.ttf" }, { "src": "https://perry-template-assets.s3.us-east-2.amazonaws.com/fonts/Georgia-Bold.ttf" }, { "src": "https://perry-template-assets.s3.us-east-2.amazonaws.com/fonts/Georgia-BoldItalic.ttf" }, { "src": "https://perry-template-assets.s3.us-east-2.amazonaws.com/fonts/Georgia-Italic.ttf" }, { "src": "https://perry-template-assets.s3.us-east-2.amazonaws.com/fonts/Georgia.ttf" }, { "src": "https://perry-template-assets.s3.us-east-2.amazonaws.com/fonts/Nunito-Black.ttf" }, { "src": "https://perry-template-assets.s3.us-east-2.amazonaws.com/fonts/Nunito-BlackItalic.ttf" }, { "src": "https://perry-template-assets.s3.us-east-2.amazonaws.com/fonts/Nunito-Bold.ttf" }, { "src": "https://perry-template-assets.s3.us-east-2.amazonaws.com/fonts/Nunito-BoldItalic.ttf" }, { "src": "https://perry-template-assets.s3.us-east-2.amazonaws.com/fonts/Nunito-ExtraBold.ttf" }, { "src": "https://perry-template-assets.s3.us-east-2.amazonaws.com/fonts/Nunito-ExtraBoldItalic.ttf" }, { "src": "https://perry-template-assets.s3.us-east-2.amazonaws.com/fonts/Nunito-ExtraLight.ttf" }, { "src": "https://perry-template-assets.s3.us-east-2.amazonaws.com/fonts/Nunito-ExtraLightItalic.ttf" }, { "src": "https://perry-template-assets.s3.us-east-2.amazonaws.com/fonts/Nunito-Italic.ttf" }, { "src": "https://perry-template-assets.s3.us-east-2.amazonaws.com/fonts/Nunito-Light.ttf" }, { "src": "https://perry-template-assets.s3.us-east-2.amazonaws.com/fonts/Nunito-LightItalic.ttf" }, { "src": "https://perry-template-assets.s3.us-east-2.amazonaws.com/fonts/Nunito-Regular.ttf" }, { "src": "https://perry-template-assets.s3.us-east-2.amazonaws.com/fonts/Nunito-SemiBold.ttf" }, { "src": "https://perry-template-assets.s3.us-east-2.amazonaws.com/fonts/Nunito-SemiBoldItalic.ttf" }, { "src": "https://perry-template-assets.s3.us-east-2.amazonaws.com/fonts/TimesNewRomanPS-BoldItalicMT.ttf" }, { "src": "https://perry-template-assets.s3.us-east-2.amazonaws.com/fonts/TimesNewRomanPS-BoldMT.ttf" }, { "src": "https://perry-template-assets.s3.us-east-2.amazonaws.com/fonts/TimesNewRomanPS-ItalicMT.ttf" }, { "src": "https://perry-template-assets.s3.us-east-2.amazonaws.com/fonts/TimesNewRomanPSMT.ttf" } ], "tracks": [ { "clips": [ { "asset": { "type": "html", "html": "<p>---eventName---</p><p class='date'>---openHouseDate---</p>", "css": "p {font-family: '---primaryFont---'; text-align: center; ---primaryFontStyle---; color: #---secondaryColor---; font-size: 90px; line-height: 80%;} .date {font-size: 40px}", "width": 1080, "height": 200 }, "start": 0, "length": 4, "position": "top", "offset": { "y": 0.02 } } ] }, { "clips": [ { "asset": { "type": "html", "html": "<p class='address'>---propertyAddress---</p><p>---bedAmount--- Bed | ---bathAmount--- Bath</p><p>---propertySurface---</p><p>---currentPrice---</p>", "css": "p {color: #---primaryColor---; text-align: center; font-size: 40px; ---primaryFontStyle---; font-family: '---primaryFont---'; line-height: 80%;} .address {font-size: 60px}", "width": 980, "height": 320, "background": "#---secondaryColor---" }, "start": 0, "length": 4, "position": "bottom" } ] }, { "clips": [ { "asset": { "type": "luma", "src": "https://perry-template-assets.s3.us-east-2.amazonaws.com/luma/Template31-22-1080x1350.jpg" }, "start": 0, "length": 4 }, { "asset": { "type": "html", "html": "<div></div>", "background": "#---primaryColor---", "width": 1080, "height": 1350 }, "start": 0, "length": 4, "position": "center" } ] }, { "clips": [ { "asset": { "type": "html", "html": "<p></p>", "width": 95, "height": 695, "background": "#---secondaryColor---" }, "start": 0, "length": 4, "position": "bottomLeft" } ] }, { "clips": [ { "asset": { "type": "html", "html": "<p></p>", "width": 95, "height": 695, "background": "#---secondaryColor---" }, "start": 0, "length": 4, "position": "bottomRight" } ] }, { "clips": [ { "asset": { "type": "image", "src": "---propertyPhoto1---" }, "start": 0, "length": 4, "position": "bottom", "fit": "crop", "scale": 0.8, "transition": { "in": "carouselUpSlow" }, "offset": { "y---horizontalPhoto1---": 0.24, "y---verticalPhoto1---": 0.15 } } ] }, { "clips": [ { "asset": { "type": "html", "html": "<p></p>", "width": 1080, "height": 655, "background": "#---primaryColor---" }, "start": 0, "length": 4, "position": "top" } ] }, { "clips": [ { "asset": { "type": "html", "html": "<p>---callToAction---</p>", "css": "p {color: #000000; font-size: 58px; ---secondaryFontStyle---; font-family: '---secondaryFont---'}", "width": 900, "height": 200 }, "start": 4, "length": 3, "position": "top", "transition": { "in": "fade" } }, { "asset": { "type": "html", "html": "<p class='big'>---agentFirstName--- ---agentLastName---</p><p>---agentTitle---</p><p>---agentEmail---</p><p>---agentPhone---</p><p class='small'><br />---agentFirmName---<br />---agentFirmAddress---<br />---agentFirmWebsite---</p>", "css": "p {color: #000000; font-size: 30px; ---secondaryFontStyle---; font-family: '---secondaryFont---'; margin-top: 0; margin-bottom: 0} .big {font-size: 58px} .small {font-size: 24px}", "width": 900, "height": 540 }, "start": 4, "length": 3, "position": "bottom", "offset": { "y": 0.02 }, "transition": { "in": "fade" } } ] }, { "clips": [ { "asset": { "type": "luma", "src": "https://perry-template-assets.s3.us-east-2.amazonaws.com/luma/circle-1080x1350agent.jpg" }, "start": 4, "length": 3 }, { "asset": { "type": "html", "html": "<div></div>", "background": "#D9---secondaryColor---", "width": 1080, "height": 1350 }, "start": 4, "length": 3, "position": "center" } ] }, { "clips": [ { "asset": { "type": "image", "src": "---agentPhoto---" }, "start": 4, "length": 3, "fit": "crop", "scale---horizontalAgentPhoto---": 0.5, "scale---verticalAgentPhoto---": 0.6, "position": "top", "offset": { "y---horizontalAgentPhoto---": -0.12, "y---verticalAgentPhoto---": -0.135 }, "transition": { "in": "fadeFast" } } ] } ], "cache": true }, "output": { "format": "mp4", "resolution": "1080", "aspectRatio": "4:5", "quality": "medium", "poster": { "capture": 2 }, "destinations": [ { "provider": "shotstack", "exclude": true } ] } }`; const subst = ``; // 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