Regular Expressions 101

Save & Share

  • Regex Version: ver. 2
  • 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

/
/
g

Test String

Substitution

Processing...

Code Generator

Generated Code

re = /#EXTVDJ:.*?[0-9]+.*?t>(.*?)<.*?e>(.*?)<.*?\n.*?mp3/ str = '#EXTVDJ:<filesize>16027776</filesize><artist>Kyau & Albert, Steve Brian</artist><title>Reverie (DJ Version)</title><songlength>397.340</songlength> E:\\Music\\For Sorting\\From USB Stick\\Music\\2017-19\\10932465_Reverie_DJ_Version.mp3 #EXTVDJ:<filesize>14624215</filesize><artist>Paul van Dyk, KINETICA</artist><title>First Contact (Original Mix)</title><songlength>361.739</songlength> E:\\Music\\For Sorting\\July 2020\\13319740_First_Contact_Original_Mix.mp3 #EXTVDJ:<filesize>16609012</filesize><artist>Solarstone, Meredith Call</artist><title>I Found You (Giuseppe Ottaviani Remix)</title><songlength>410.929</songlength> E:\\Music\\For Sorting\\From USB Stick\\Music\\2017-19\\9710365_I_Found_You_Giuseppe_Ottaviani_Remix.mp3 #EXTVDJ:<filesize>13277361</filesize><artist>Darude, Ashley Wallbridge, Foux</artist><title>Surrender feat. Foux (Extended Mix)</title><songlength>328.918</songlength> E:\\Music\\For Sorting\\From USB Stick\\Music\\2017-19\\10161893_Surrender_feat__Foux_Extended_Mix.mp3 #EXTVDJ:<filesize>21313586</filesize><artist>Ciaran McAuley, Clare Stagg</artist><title>All I Want (Mark Sherry Extended Remix)</title><songlength>526.866</songlength> E:\\Music\\For Sorting\\July 2020\\13446725_All_I_Want_Mark_Sherry_Extended_Remix.mp3 #EXTVDJ:<filesize>15246761</filesize><artist>Cosmic Gate, Denise Rivera</artist><title>Body Of Conflict (Elevven Extended Remix)</title><songlength>377.681</songlength> E:\\Music\\For Sorting\\July 2020\\12462485_Body_Of_Conflict_Elevven_Extended_Remix.mp3 #EXTVDJ:<filesize>17663564</filesize><artist>Philippe El Sisi, Omar Sherif</artist><title>Demolition (Original Mix)</title><songlength>438.857</songlength> E:\\Music\\For Sorting\\July 2020\\13498731_Demolition_Original_Mix.mp3 #EXTVDJ:<filesize>13108166</filesize><artist>Alex Kunnari</artist><title>Sundown (Extended Mix)</title><songlength>323.138</songlength> E:\\Music\\For Sorting\\From USB Stick\\Music\\2017-19\\10689952_Sundown_Extended_Mix.mp3 #EXTVDJ:<filesize>16468045</filesize><artist>Chris Schweizer</artist><title>Don\'t Be Scared (Extended Mix)</title><songlength>408.696</songlength> E:\\Music\\For Sorting\\July 2020\\13609598_Don_t_Be_Scared_Extended_Mix.mp3 #EXTVDJ:<filesize>15035754</filesize><artist>Dan Stone, Victoriya</artist><title>I Can\'t Tell (Ferry Tayle Extended Remix)</title><songlength>372.702</songlength> E:\\Music\\For Sorting\\July 2020\\13689560_I_Can_t_Tell_Ferry_Tayle_Extended_Remix.mp3 #EXTVDJ:<filesize>16562928</filesize><artist>Seri, Nifra</artist><title>Edge of Time feat. Seri (Extended Mix)</title><songlength>410.285</songlength> E:\\Music\\For Sorting\\From USB Stick\\Music\\2017-19\\9090018_Edge_of_Time_feat__Seri_Extended_Mix.mp3 #EXTVDJ:<filesize>15886841</filesize><artist>Claus Backslash</artist><title>Absolute Delusion (Extended Mix)</title><songlength>395.294</songlength> E:\\Music\\For Sorting\\July 2020\\13741469_Absolute_Delusion_Extended_Mix.mp3 #EXTVDJ:<filesize>18052845</filesize><artist>Sivan, Graham Bell</artist><title>The Sound Of Letting Go (Tribute To Yotam) (Extended Mix)</title><songlength>448.333</songlength> E:\\Music\\For Sorting\\July 2020\\13674262_The_Sound_Of_Letting_Go__Tribute_To_Yotam__Extended_Mix.mp3 ' subst = '$1 - $2' result = str.gsub(re, subst) # Print the result of the substitution puts 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 Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html