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

/
/
gms

Test String

Substitution

Processing...

Code Generator

Generated Code

$re = '/.*?"artwork" href="(https:\/\/www\.beatport\.com\/release\/.*?\/\d+)"><img.*?|.*?<\/html>/ms'; $str = 'href="/icons/sprite.svg#arrow-forward"></use></svg></a></div></div><div class="sc-cdd38545-7 cvVSaF"><div role="table" class="sc-e751ecad-4 eudvka"><div class="sc-e751ecad-3 hLolpn row"><div class="sc-e751ecad-0 cNVqXt controls" role="cell">&nbsp;</div><div class="sc-e751ecad-0 cNVqXt title" role="cell">Title / Artists</div><div class="sc-e751ecad-0 cNVqXt label" role="cell">Label</div><div class="sc-e751ecad-0 cNVqXt bpm" role="cell">BPM</div><div class="sc-e751ecad-0 cNVqXt date" role="cell">Release Date</div><div class="sc-e751ecad-0 cNVqXt card" role="cell">&nbsp;</div></div><div class="sc-e751ecad-2 jwfQBB"><div class="sc-e751ecad-1 gSaMFX row"><div class="sc-e751ecad-0 cNVqXt controls" role="cell"><div class="sc-cdd38545-6 ZuJgX"><a title="Cozy Shores" class="artwork" href="https://www.beatport.com/release/cozy-shores/4151883"><img alt="Cozy Shores" loading="lazy" width="38" height="38" decoding="async" data-nimg="1" src="https://geo-media.beatport.com/image_size/250x250/a8cf485e-9579-4385-9bf7-c9e4b73dbca8.jpg" style="color: transparent;"></a><span class="fade"><button class="sc-a89217b5-0 fJWJNw"><svg width="11" height="16" fill="white" title="Play" desc="Play button"><use href="/icons/sprite.svg#track-play-inline"></use></svg></button></span><span class="fade"><div class="sc-7556433-1 brrero"><button class="sc-343650ac-0 bbYDnQ"><svg width="16" height="15"><use href="/icons/sprite.svg#queue-add"></use></svg></button><div class="sc-7556433-0 tMxzN top">Add to queue</div></div></span><span class="fade"><div class="sc-7556433-1 brrero"><button class="sc-343650ac-0 bbYDnQ"><svg width="14" height="14"><use href="/icons/sprite.svg#playlist-add"></use></svg></button><div class="sc-7556433-0 tMxzN top">Add to playlist</div></div></span></div></div><div class="sc-e751ecad-0 cNVqXt cell title" role="cell"><div class="container"><a title="Cozy Shores" href="https://www.beatport.com/release/cozy-shores/4151883"><span class="sc-cdd38545-4 erNSOX">Cozy Shores </span></a><div class="sc-d6bcf006-0 eOcWlw"><a title="Alexey Lukianov" href="https://www.beatport.com/artist/alexey-lukianov/961088">Alexey Lukianov</a></div></div></div><div class="sc-e751ecad-0 cNVqXt cell label" role="cell"><a title="Neostatics Sounds" href="https://www.beatport.com/label/neostatics-sounds/35430">Neostatics Sounds</a></div><div class="sc-e751ecad-0 cNVqXt cell bpm" role="cell">138 BPM</div><div class="sc-e751ecad-0 cNVqXt cell date" role="cell">2023-07-10</div><div class="sc-e751ecad-0 cNVqXt cell card" role="cell"><span class="fade"><button class="sc-aa9d0f71-0 gvtSBc add-to-cart"><span class="price">$3.87</span><span class="arrow"><i></i></span></button></span></div></div><div class="sc-e751ecad-1 gSaMFX row"><div class="sc-e751ecad-0 cNVqXt controls" role="cell"><div class="sc-cdd38545-6 ZuJgX"><a title="Hope" class="artwork" href="https://www.beatport.com/release/hope/4148041"><img alt="Hope" loading="lazy" width="38" height="38" decoding="async" data-nimg="1" src="https://geo-media.beatport.com/image_size/250x250/30724a9b-909c-49a3-912b-2fb166f1f4a0.jpg" style="color: transparent;"></a><span class="fade"><button class="sc-a89217b5-0 fJWJNw"><svg width="11" height="16" fill="white" title="Play" desc="Play button"><use href="/icons/sprite.svg#track-play-inline"></use></svg></button></span><span class="fade"><div class="sc-7556433-1 brrero"><button class="sc-343650ac-0 bbYDnQ"><svg width="16" height="15"><use href="/icons/sprite.svg#queue-add"></use></svg></button><div class="sc-7556433-0 tMxzN top">Add to queue</div></div></span><span class="fade"><div class="sc-7556433-1 brrero"><button class="sc-343650ac-0 bbYDnQ"><svg width="14" height="14"><use href="/icons/sprite.svg#playlist-add"></use></svg></button><div class="sc-7556433-0 tMxzN top">Add to playlist</div></div></span></div></div><div class="sc-e751ecad-0 cNVqXt cell title" role="cell"><div class="container"><a title="Hope" href="https://www.beatport.com/release/hope/4148041"><span class="sc-cdd38545-4 erNSOX">Hope </span></a><div class="sc-d6bcf006-0 eOcWlw"><a title="SinStar" href="https://www.beatport.com/artist/sinstar/685290">SinStar</a></div></div></div><div class="sc-e751ecad-0 cNVqXt cell label" role="cell"><a title="Neostatics Sounds" href="https://www.beatport.com/label/neostatics-sounds/35430">Neostatics Sounds</a></div><div class="sc-e751ecad-0 cNVqXt cell bpm" role="cell">105-140 BPM</div><div class="sc-e751ecad-0 cNVqXt cell date" role="cell">2023-07-07</div><div class="sc-e751ecad-0 cNVqXt cell card" role="cell"><span class="fade"><button class="sc-aa9d0f71-0 gvtSBc add-to-cart"><span class="price">$3.87</span><span class="arrow"><i></i></span></button></span></div></div><div class="sc-e751ecad-1 gSaMFX row"><div class="sc-e751ecad-0 cNVqXt controls" role="cell"><div class="sc-cdd38545-6 ZuJgX"><a title="Vena Amoris" class="artwork" href="https://www.beatport.com/release/vena-amoris/4144915"><img alt="Vena Amoris" loading="lazy" width="38" height="38" decoding="async" data-nimg="1" src="https://geo-media.beatport.com/image_size/250x250/3d21570f-fe19-474c-be35-8cb8e94cd054.jpg" style="color: transparent;"></a><span class="fade"><button class="sc-a89217b5-0 fJWJNw"><svg width="11" height="16" fill="white" title="Play" desc="Play button"><use href="/icons/sprite.svg#track-play-inline"></use></svg></button></span><span class="fade"><div class="sc-7556433-1 brrero"><button class="sc-343650ac-0 bbYDnQ"><svg width="16" height="15"><use href="/icons/sprite.svg#queue-add"></use></svg></button><div class="sc-7556433-0 tMxzN top">Add to queue</div></div></span><span class="fade"><div class="sc-7556433-1 brrero"><button class="sc-343650ac-0 bbYDnQ"><svg width="14" height="14"><use href="/icons/sprite.svg#playlist-add"></use></svg></button><div class="sc-7556433-0 tMxzN top">Add to playlist</div></div></span></div></div><div class="sc-e751ecad-0 cNVqXt cell title" role="cell"><div class="container"><a title="Vena Amoris" href="https://www.beatport.com/release/vena-amoris/4144915"><span class="sc-cdd38545-4 erNSOX">Vena Amoris </span></a><div class="sc-d6bcf006-0 eOcWlw"><a title="Double Kay" href="https://www.beatport.com/artist/double-kay/1001280">Double Kay</a></div></div></div><div class="sc-e751ecad-0 cNVqXt cell label" role="cell"><a title="Neostatics Sounds" href="https://www.beatport.com/label/neostatics-sounds/35430">Neostatics Sounds</a></div><div class="sc-e751ecad-0 cNVqXt cell bpm" role="cell">127 BPM</div><div class="sc-e751ecad-0 cNVqXt cell date" role="cell">2023-07-04</div><div class="sc-e751ecad-0 cNVqXt cell card" role="cell"><span class="fade"><button class="sc-aa9d0f71-0 gvtSBc add-to-cart"><span class="price">$2.58</span><span class="arrow"><i></i></span></button></span></div></div><div class="sc-e751ecad-1 gSaMFX row"><div class="sc-e751ecad-0 cNVqXt controls" role="cell"><div class="sc-cdd38545-6 ZuJgX"><a title="Tartu" class="artwork" href="https://www.beatport.com/release/tartu/4138691"><img alt="Tartu" loading="lazy" width="38" height="38" decoding="async" data-nimg="1" src="https://geo-media.beatport.com/image_size/250x250/98c8729c-1f93-49e9-b78c-48f56bc805db.jpg" style="color: transparent;"></a><span class="fade"><button class="sc-a89217b5-0 fJWJNw"><svg width="11" height="16" fill="white" title="Play" desc="Play button"><use href="/icons/sprite.svg#track-play-inline"></use></svg></button></span><span class="fade"><div class="sc-7556433-1 brrero"><button class="sc-343650ac-0 bbYDnQ"><svg width="16" height="15"><use href="/icons/sprite.svg#queue-add"></use></svg></button><div class="sc-7556433-0 tMxzN top">Add to queue</div></div></span><span class="fade"><div class="sc-7556433-1 brrero"><button class="sc-343650ac-0 bbYDnQ"><svg width="14" height="14"><use href="/icons/sprite.svg#playlist-add"></use></svg></button><div class="sc-7556433-0 tMxzN top">Add to playlist</div></div></span></div></div><div class="sc-e751ecad-0 cNVqXt cell title" role="cell"><div class="container"><a title="Tartu" href="https://www.beatport.com/release/tartu/4138691"><span class="sc-cdd38545-4 erNSOX">Tartu </span></a><div class="sc-d6bcf006-0 eOcWlw"><a title="Eugene K" href="https://www.beatport.com/artist/eugene-k/269803">Eugene K</a></div></div></div><div class="sc-e751ecad-0 cNVqXt cell label" role="cell"><a title="Neostatics Sounds" href="https://www.beatport.com/label/neostatics-sounds/35430">Neostatics Sounds</a></div><div class="sc-e751ecad-0 cNVqXt cell bpm" role="cell">125-142 BPM</div><div class="sc-e751ecad-0 cNVqXt cell date" role="cell">2023-06-29</div><div class="sc-e751ecad-0 cNVqXt cell card" role="cell"><span class="fade"><button class="sc-aa9d0f71-0 gvtSBc add-to-cart"><span class="price">$2.58</span><span class="arrow"><i></i></span></button></span></div></div><div class="sc-e751ecad-1 gSaMFX row"><div class="sc-e751ecad-0 cNVqXt controls" role="cell"><div class="sc-cdd38545-6 ZuJgX"><a title="The Long Return" class="artwork" href="https://www.beatport.com/release/the-long-return/4136619"><img alt="The Long Return" loading="lazy" width="38" height="38" decoding="async" data-nimg="1" src="https://geo-media.beatport.com/image_size/250x250/fff2d415-646f-4e03-a6f7-b23f8a6233c5.jpg" style="color: transparent;"></a><span class="fade"><button class="sc-a89217b5-0 fJWJNw"><svg width="11" height="16" fill="white" title="Play" desc="Play button"><use href="/icons/sprite.svg#track-play-inline"></use></svg></button></span><span class="fade"><div class="sc-7556433-1 brrero"><button class="sc-343650ac-0 bbYDnQ"><svg width="16" heigh</html>'; $subst = "$1\n"; $result = preg_replace($re, $subst, $str); echo "The result of the substitution is ".$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 PHP, please visit: http://php.net/manual/en/ref.pcre.php