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
  • Match everything enclosed
    (?:...)
  • Capture everything enclosed
    (...)
  • 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

r"
"
g

Test String

Code Generator

Generated Code

re = /,\s*file\s*:\s*"?\'?([^"\']*)/ str = 'jwplayer("vplayer").setup({sources:[{description:\'82yekcjjfnp8\',file:rtmp://149.202.80.234:19350/vod/mp4:01/00146/82yekcjjfnp8_n?h=h75fusefglekalhulo4ta4uxasktzhpsp4ptbjlplp7quqflff7nytwrypwq\'},{description:\'82yekcjjfnp8\',file:"http://149.202.80.234/h75fusefglekalhulo4ta4uxasktzhpsp4ptbjlplp7quqflff7nytwrypwq/v.mp4"}],image:"http://149.202.80.234/i/01/00146/82yekcjjfnp8.jpg",duration:"3148",width:"100%",height:"100%",primary:"flash",androidhls:"true",startparam:"start",plugins:{"http://streamplay.to/player6/lightsout.js":{}},tracks:[],captions:{color:\'#dacf84\',fontSize:16,fontFamily:"Arial",backgroundOpacity:0},"sharing":{code:"%3CIFRAME SRC%3D%22http%3A%2F%2Fstreamplay.to%2Fembed-82yekcjjfnp8.html%22 FRAMEBORDER%3D0 MARGINWIDTH%3D0 MARGINHEIGHT%3D0 SCROLLING%3DNO allowfullscreen%3D%22true%22 WIDTH%3D954 HEIGHT%3D537%3E%3C%2FIFRAME%3E",link:"http://streamplay.to/82yekcjjfnp8"},rtmp:{bufferlength:5},stretching:\'uniform\',abouttext:\'StreamPlay 6.0\',aboutlink:\'http://streamplay.to\',logo:{file:\'http://streamplay.to/favicon-48x48.png\',hide:true,link:\'http://streamplay.to/\',margin:12}});var vvplay,vvad;var tt730250=0;var p0730250=0;jwplayer().onSeek(function(x){p0730250=-1});jwplayer().onTime(function(x){if(p0730250>0)tt730250+=x.position-p0730250;p0730250=x.position;if(0!=0&&tt730250>=0){p0730250=-1;jwplayer().stop();jwplayer().setFullscreen(false);$(\'#play_limit_box\').show();$(\'div.video_ad\').show()}if(5>0&&tt730250>=5&&vvad!=1){vvad=1;$(\'div.video_ad_fadein\').fadeIn(\'slow\')}});jwplayer().onPlay(function(x){doPlay(x)});jwplayer().onComplete(function(){$(\'div.video_ad\').show()});jwplayer().onReady(function(){if(isPlayerReady)isPlayerReady()});function getMediaId(){return\'2020\'};function getDesc(){return\'82yekcjjfnp8\'};function sendGa(category,extra){if(typeof ga==\'function\')ga(\'send\',\'event\',category,getDesc(),getMediaId()+(extra?\' \'+extra:\'\'))};function doPlay(x){$(\'div.video_ad\').hide();if(vvplay)return;vvplay=1;$.get(\'http://streamplay.to/dl?op=view&file_code=82yekcjjfnp8&hash=730250-84-0-1471898347-bf33ea5e51b77e725853a3a36e6fbdf7\');if(jwplayer().getPosition()==0)sendGa(\'Play\')}' # Print the match result str.scan(re) do |match| puts match.to_s end

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