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

/
/
gm

Test String

Code Generator

Generated Code

const regex = /(\[)((\/?vc_)|(divider)|(image_)|(nectar_))([\w\s="'\-_.\/,:?&\/;%]*)(\])/gm; // Alternative syntax using RegExp constructor // const regex = new RegExp('(\\[)((\\\/?vc_)|(divider)|(image_)|(nectar_))([\\w\\s="\'\\-_.\\\/,:?&\\\/;%]*)(\\])', 'gm') const str = ` <wp:status>publish</wp:status> <pubDate>Thu, 21 Jul 2022 14:19:17 +0000</pubDate> <wp:post_date>2022-07-21 14:19:17</wp:post_date> <wp:post_date_gmt>2022-07-21 14:19:17</wp:post_date_gmt> <category domain="post_tag" nicename="architect"><![CDATA[architect]]></category> <category domain="post_tag" nicename="bernardo-wills"><![CDATA[bernardo wills]]></category> <category domain="post_tag" nicename="city"><![CDATA[city]]></category> <category domain="post_tag" nicename="coeur-dalene"><![CDATA[coeur d'alene]]></category> <category domain="post_tag" nicename="design"><![CDATA[design]]></category> <category domain="post_tag" nicename="landscape"><![CDATA[landscape]]></category> <category domain="post_tag" nicename="mceuen-park"><![CDATA[mceuen park]]></category> <category domain="post_tag" nicename="north-idaho"><![CDATA[north idaho]]></category> <category domain="post_tag" nicename="park"><![CDATA[park]]></category> <category domain="post_tag" nicename="planning"><![CDATA[planning]]></category> <category domain="category" nicename="architecture"><![CDATA[Architecture]]></category> <category domain="category" nicename="landscape-design"><![CDATA[Landscape Design]]></category> <category domain="category" nicename="news"><![CDATA[News]]></category> <dc:creator /> <wp:comment_status>open</wp:comment_status> </item> <item> <title>Riverfront Park North Bank and Ice Age Floods Playground</title> <link>/blog/riverfront-park-north-bank-and-ice-age-floods-playground</link> <content:encoded><![CDATA[<p> <div data-contents="true"> <div class="" data-block="true" data-editor="3h4f0" data-offset-key="f1lji-0-0"> <div class="_1mf _1mj" data-offset-key="f1lji-0-0"><span data-offset-key="f1lji-0-0">This week we are reflecting on some of the highlights from 2021 – one of which is the completion and opening of the North Bank Regional Playground in Riverfront Park. The North Bank Regional Playground project is one of five major park elements identified in the Riverfront Park Master Plan that was funded in 2014 with a \$64 million bond to redevelop the park. The site includes a themed regional playground, splash pad, open play area, specialty basketball court, wheels park, landscaping, lighting, new maintenance and operations/public restroom facility, and parking with innovative stormwater solutions. The one-acre Ice Age Floods Playground was designed as an outdoor learning and play experience that tells the story of how the Ice Age Floods shaped our region. Because of the dynamic nature of the Ice Age Floods and the rich imagery of its components, the story was transformed into an exciting play environment that also offers, multi-generational learning opportunities. It aims to provide a completely interactive and fun way for children, families and interested people to learn about our region’s unique geologic history.</span></div> </div> <div class="" data-block="true" data-editor="3h4f0" data-offset-key="1gltj-0-0"> <div class="_1mf _1mj" data-offset-key="1gltj-0-0"><span data-offset-key="1gltj-0-0"> </span></div> </div> <div class="" data-block="true" data-editor="3h4f0" data-offset-key="7nomr-0-0"> <div class="_1mf _1mj" data-offset-key="7nomr-0-0"><span data-offset-key="7nomr-0-0">The goal of the playground was to create an adaptive, safe, dynamic, high-quality nature-based play/learn environment for children of all abilities and their families. Bernardo Wills Architects led a large consultant group that included our in-house architecture team.</span></div> </div> </div> <p></p>]]></content:encoded> <excerpt:encoded><![CDATA[<p>This week we are reflecting on some of the highlights from 2021 – one of which is the completion and opening of the North Bank Regional Playground in Riverfront Park.</p>]]></excerpt:encoded> <wp:post_name>riverfront-park-north-bank-and-ice-age-floods-playground</wp:post_name> <wp:post_type>post</wp:post_type> <wp:post_id>24</wp:post_id> <wp:status>publish</wp:status> <pubDate>Mon, 27 Dec 2021 16:18:57 +0000</pubDate> <wp:post_date>2021-12-27 16:18:57</wp:post_date> <wp:post_date_gmt>2021-12-27 16:18:57</wp:post_date_gmt> <category domain="post_tag" nicename="architects"><![CDATA[architects]]></category> <category domain="post_tag" nicename="bernardo-wills"><![CDATA[bernardo wills]]></category> <category domain="post_tag" nicename="landscape-architect"><![CDATA[landscape architect]]></category> <category domain="post_tag" nicename="north-bank"><![CDATA[north bank]]></category> <category domain="post_tag" nicename="park"><![CDATA[park]]></category> <category domain="post_tag" nicename="playground"><![CDATA[playground]]></category> <category domain="post_tag" nicename="river"><![CDATA[river]]></category> <category domain="post_tag" nicename="spokane"><![CDATA[Spokane]]></category> <category domain="category" nicename="architecture"><![CDATA[Architecture]]></category> <category domain="category" nicename="construction"><![CDATA[Construction]]></category> <category domain="category" nicename="landscape-design"><![CDATA[Landscape Design]]></category> <category domain="category" nicename="news"><![CDATA[News]]></category> <dc:creator /> <wp:comment_status>open</wp:comment_status> </item> <item> <title>Vietnam Veterans Memorial</title> <link>/blog/vietnam-veterans-memorial-rededication</link> <content:encoded><![CDATA[<p><span data-sheets-value="{&quot;1&quot;:2,&quot;2&quot;:&quot;Veterans Day was even more special for our Bernardo Wills Architects design team, as we got to celebrate the redesign and rededication of the Vietnam Veterans Memorial in Riverfront Park. The new design includes a plaza that is wheelchair accessible, new benches, a decorative hand rail, and lighting. We are proud to have donated our design services for this important memorial to our local veterans.\\n\\nhttps://www.spokesman.com/stories/2021/nov/11/vietnam-veterans-reminisce-heal-as-spokane-rededic/&quot;}" data-sheets-userformat="{&quot;2&quot;:1053547,&quot;3&quot;:{&quot;1&quot;:0},&quot;4&quot;:{&quot;1&quot;:2,&quot;2&quot;:12081720},&quot;6&quot;:{&quot;1&quot;:[{&quot;1&quot;:2,&quot;2&quot;:0,&quot;5&quot;:{&quot;1&quot;:2,&quot;2&quot;:0}},{&quot;1&quot;:0,&quot;2&quot;:0,&quot;3&quot;:3},{&quot;1&quot;:1,&quot;2&quot;:0,&quot;4&quot;:1}]},&quot;8&quot;:{&quot;1&quot;:[{&quot;1&quot;:2,&quot;2&quot;:0,&quot;5&quot;:{&quot;1&quot;:2,&quot;2&quot;:0}},{&quot;1&quot;:0,&quot;2&quot;:0,&quot;3&quot;:3},{&quot;1&quot;:1,&quot;2&quot;:0,&quot;4&quot;:1}]},&quot;9&quot;:1,&quot;11&quot;:4,&quot;12&quot;:0,&quot;15&quot;:&quot;arial,sans,sans-serif&quot;,&quot;23&quot;:1}" data-sheets-textstyleruns="{&quot;1&quot;:0}{&quot;1&quot;:402,&quot;2&quot;:{&quot;2&quot;:{&quot;1&quot;:2,&quot;2&quot;:0}}}{&quot;1&quot;:403,&quot;2&quot;:{&quot;2&quot;:{&quot;1&quot;:2,&quot;2&quot;:1136076},&quot;9&quot;:1}}" data-sheets-hyperlinkruns="{&quot;1&quot;:402,&quot;2&quot;:&quot;https://www.spokesman.com/stories/2021/nov/11/vietnam-veterans-reminisce-heal-as-spokane-rededic/&quot;}{&quot;1&quot;:496}">Veterans Day was even more special for our Bernardo Wills Architects design team, as we got to celebrate the redesign and rededication of the Vietnam Veterans Memorial in Riverfront Park. The new design includes a plaza that is wheelchair accessible, new benches, a decorative handrail, and lighting. We are proud to have donated our design services for this important memorial to our local veterans.</span>[nectar_btn size="medium" button_style="regular" button_color_2="Accent-Color" icon_family="none" url="https://www.spokesman.com/stories/2021/nov/11/vietnam-veterans-reminisce-heal-as-spokane-rededic/" text="Read the Spokesman-Review Article"]</p>]]></content:encoded>`; // Reset `lastIndex` if this regex is defined globally // regex.lastIndex = 0; let m; while ((m = regex.exec(str)) !== null) { // This is necessary to avoid infinite loops with zero-width matches if (m.index === regex.lastIndex) { regex.lastIndex++; } // The result can be accessed through the `m`-variable. m.forEach((match, groupIndex) => { console.log(`Found match, group ${groupIndex}: ${match}`); }); }

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