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

/
/
g

Test String

Code Generator

Generated Code

const regex = /.*images\/(?!cached).*/g; // Alternative syntax using RegExp constructor // const regex = new RegExp('.*images\\\/(?!cached).*', 'g') const str = `./images/logos/partners/mastergen.png ./images/logos/partners/highland.png ./images/logos/partners/charollais.png ./images/logos/partners/grasstec.png ./images/logos/partners/stabiliser.png ./images/logos/services ./images/logos/services/farmpay-icon.png ./images/cached ./images/cached/.DS_Store ./images/cached/logo-farmpay-black.png ./images/cached/logo-green-text.svg ./images/cached/readme.md ./images/cached/logo-green-icon.svg ./images/cached/logo-green-icon.png ./images/cached/logo-farmpay-white.png ./images/cached/logo-white-text.svg ./images/cached/logo-green.png ./images/user ./images/user/.DS_Store ./images/user/shield.svg ./images/user/shield-error.svg ./images/user/test-delete.png ./images/user/locked-avatar.png ./images/user/unknown-avatar.png ./images/listing-photo-guides ./images/listing-photo-guides/goats ./images/listing-photo-guides/goats/.DS_Store ./images/listing-photo-guides/goats/bad ./images/listing-photo-guides/goats/bad/1.png ./images/listing-photo-guides/goats/good ./images/listing-photo-guides/goats/good/1.png ./images/listing-photo-guides/pigs ./images/listing-photo-guides/pigs/.DS_Store ./images/listing-photo-guides/pigs/bad ./images/listing-photo-guides/pigs/bad/2.png ./images/listing-photo-guides/pigs/bad/1.png ./images/listing-photo-guides/pigs/good ./images/listing-photo-guides/pigs/good/2.png ./images/listing-photo-guides/pigs/good/1.png ./images/listing-photo-guides/.DS_Store ./images/listing-photo-guides/dairy-cattle ./images/listing-photo-guides/dairy-cattle/.DS_Store images/listing-photo-guides/dairy-cattle/bad ./images/listing-photo-guides/dairy-cattle/bad/2.png ./images/listing-photo-guides/dairy-cattle/bad/3.png ./images/listing-photo-guides/dairy-cattle/bad/1.png ./images/listing-photo-guides/dairy-cattle/good ./images/listing-photo-guides/dairy-cattle/good/2.png ./images/listing-photo-guides/dairy-cattle/good/3.png ./images/listing-photo-guides/dairy-cattle/good/1.png ./images/listing-photo-guides/sheep ./images/listing-photo-guides/sheep/.DS_Store ./images/listing-photo-guides/sheep/bad ./images/listing-photo-guides/sheep/bad/4.png ./images/listing-photo-guides/sheep/bad/2.png ./images/listing-photo-guides/sheep/bad/3.png ./images/listing-photo-guides/sheep/bad/1.png ./images/listing-photo-guides/sheep/good ./images/listing-photo-guides/sheep/good/4.png ./images/listing-photo-guides/sheep/good/2.png ./images/listing-photo-guides/sheep/good/3.png ./images/listing-photo-guides/sheep/good/1.png ./images/listing-photo-guides/breeding-cattle ./images/listing-photo-guides/breeding-cattle/.DS_Store ./images/listing-photo-guides/breeding-cattle/bad ./images/listing-photo-guides/breeding-cattle/bad/4.png ./images/listing-photo-guides/breeding-cattle/bad/2.png ./images/listing-photo-guides/breeding-cattle/bad/3.png ./images/listing-photo-guides/breeding-cattle/bad/1.png ./images/listing-photo-guides/breeding-cattle/good ./images/listing-photo-guides/breeding-cattle/good/4.png ./images/listing-photo-guides/breeding-cattle/good/2.png ./images/listing-photo-guides/breeding-cattle/good/3.png ./images/listing-photo-guides/breeding-cattle/good/1.png ./images/listing-photo-guides/store-cattle ./images/listing-photo-guides/store-cattle/.DS_Store ./images/listing-photo-guides/store-cattle/bad ./images/listing-photo-guides/store-cattle/bad/2.png ./images/listing-photo-guides/store-cattle/bad/1.png ./images/listing-photo-guides/store-cattle/good ./images/listing-photo-guides/store-cattle/good/2.png ./images/listing-photo-guides/store-cattle/good/1.png ./images/backgrounds ./images/backgrounds/auctions.jpg ./images/backgrounds/family-cows.jpg ./images/backgrounds/tablet-livestock.jpg ./images/backgrounds/dna-strand.jpg ./images/backgrounds/apps.jpg ./images/backgrounds/.DS_Store ./images/backgrounds/handshake-livestock.jpg ./images/backgrounds/cows.jpg ./images/backgrounds/sheep.jpg ./images/backgrounds/premium-seller.jpg ./images/backgrounds/handshake-trade.jpg ./images/backgrounds/haulage-trailer.jpg ./images/backgrounds/uk-map.png ./images/backgrounds/vet.jpg ./images/team ./images/team/kate-jones.jpg ./images/team/michelle-shores.jpg ./images/team/dan-luff.jpg ./images/team/.DS_Store ./images/team/sam-scott.jpg ./images/team/andrew-loftus.jpg ./images/team/ben-stanley.jpg ./images/team/rosie-hetherington.jpg ./images/team/derek-lewis.jpg ./images/team/peter-ellis.jpg ./images/team/andrew-huxham.jpg ./images/team/alex-crooks.jpg ./images/team/bertie-steggles.jpg ./images/team/jamie-mcinnes.jpg ./images/team/patrick-bidwell.jpg ./images/team/dave-rose.jpg ./images/team/becky-smith.jpg ./images/team/andrew-connon.jpg ./images/team/karen-johnson.jpg ./scss ./scss/config ./scss/config/_variables.scss ./scss/vendor.scss ./scss/components ./scss/components/blog.scss ./scss/components/button.scss ./scss/components/table.scss ./scss/components/forms.scss ./scss/components/layout.scss ./scss/components/tag.scss ./scss/components/tooltip.scss ./scss/components/typography.scss ./scss/components/animations.scss ./scss/components/utility.scss ./scss/components/loading.scss ./scss/app.scss ./native-app ./native-app/generated ./native-app/generated/.DS_Store ./native-app/generated/ios ./native-app/generated/ios/splash ./native-app/generated/ios/splash/Default-568h@2x~`; // 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