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

/
/
gmi

Test String

Code Generator

Generated Code

const regex = /(\ban?|\b)test(ing|s|\d|\b)/gmi; // Alternative syntax using RegExp constructor // const regex = new RegExp('(\\ban?|\\b)test(ing|s|\\d|\\b)', 'gmi') const str = `this is a test just a test atest testament antest latest Test3 da bestest script ev4r test#3 New Userscript test make sure that you have this one installed too. https://greasyfork.org/en/scripts/381982-new-userscript rere test test test script test script 1 Delicious Favicon Tweak - Test - Not Working Tweak of "Favilink" for Delcious : Adds a favicon to all links XHR without barriers -- test Scripting is fun TEST all tests for my extensions Simple test script Give a table to help manage cities Test Script Cross Domain POST All tests are outputed to developer javascript console (try F12 hotkey) ~ test ~ Enhances your experience on HackForums! c: Naruto-Boards Test Skin Changes NB layout Wanikani Review Count Analysis [TEST] Reports review counts. TM test show SI and REREC in TM Player page test test doing Politics and War Helper - Test Server Adds useful functions to the Game Politics and War - Test Server test 444 Agar ztx" Test Alert Test test test desc WME TTS test Play TTS Fur Affinity Test UI Homepage Original concept art by Mailylion. Replaces the landing page with a new theme. AH Clan Extension test #1 D - Double Split -|- S - Triple Split -|- A - 16 Split -|- Q - Feed Test Tampermonkey by Marvin try to take over the world! Test Bot cok New Free Agar.io Bot Service! JV Notes de test Affiche les notes des jeux sur la page de listing test for dual extestion try to take over the world! test なんでも良いからテストでインストールしたい人へ PTE Cheat Test Server auto PTE-Cheat Tải nhạc video và hình ảnh từ youtube test Download nhạc chất lượng cao tại mp3.zing.vn (chỉ áp dụng cho bài hát kô bao gồm album) và nút tải nhạc ở youtube LAUFLICHTS UPDaTES TEST wer faul ist und klicks ersparen will nimmt dieses script TurkerHub Speech Recognition test. Testing out Chrome's current variant of the Speech Recognition API on our favorite mark, TurkerHub. Test Testing Timer Discrepancy Test Timer descrepancy test to demonstrate background tab timer throttling. Runs on TurkerHub and displays results in the tab's title bar. Dynamic Code Cache and Loader Test For anything that needs automatic updates, for people who are too dumb to check for themselves and for things that require more frequent updates than daily. Code Loader Target Test Test for code loader Moodle/Elearning/KMOOC test help Online Moodle/Elearning/KMOOC test help MetaBot for YouTube (test) More information about users and videos on YouTube. another test pls dont its a test for brofist.io Test 1 Adds link to original size below each image Felix Test try to take over the world! HookAjax Test ww.soundsnap.com 铃声免费下载 Test try to take over the world! 小米搶折價卷 test try to take over the world! test Sign in to External AFTLite Will log into External AFTlite automatcially TCBG test description Cross Site Test Cross Communication Xhamster (TEST) - AUTO Delete Our Deleted Favs (videos/Users) v.3 - DEV - test AUTO Delete Our Deleted Favs (videos/Users) (author of the Library in use: Brock Adams) HaxBall Test Mod See if mods work for you Test Video warnings Warns to make test videos private BrainMetrix - IQ Test Get the highest IQ on http://www.brainmetrix.com/free-iq-test/ New Reading Test Script Removed the useless verification code and easy to login. test test script `; // 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