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

/
/
gm

Test String

Code Generator

Generated Code

$re = '/nma=function\(\w\)(\{.*?return b.join\(\"\"\)\};)/m'; $str = 'blah blah before nma=function(a){var b=a.split(""),c=[951065844,1737458512,function(){for(var d=64,e=[];++d-e.length-32;)switch(d){case 58:d=96;continue;case 91:d=44;break;case 65:d=47;continue;case 46:d=153;case 123:d-=58;default:e.push(String.fromCharCode(d))}return e},-1048131915,null,510751325,1801897769,841162791,-812488775,function(d,e){e.splice(e.length,0,d)},function(d,e,f,h,l,m,n,p){return d(m,n,p)},-1197251188,129759202,1615911359,1922401406,915671085,b,-1197251188,function(d){throw d;},-469937480,function(d,e){e=(e%d.length+d.length)%d.length;d.splice(e,1)},807320547,651020512,-128509759,-1579455896,null,function(){for(var d=64,e=[];++d-e.length-32;)switch(d){case 46:d=95;default:e.push(String.fromCharCode(d));case 94:case 95:case 96:break;case 123:d-=76;case 92:case 93:continue;case 58:d=44;case 91:}return e},-1924370708,-1910003189,function(d,e){d=(d%e.length+e.length)%e.length;e.splice(-d).reverse().forEach(function(f){e.unshift(f)})},-2064763841,"}]\',",-1983224398,-643615630,1322300768,/[/,-7,/;{],,()}/,-1604202599,475433582,function(d){d.reverse()},-1947292273,b,"ja8wL-E",343164303,-857794131,409295958,function(d,e){0!=d.length&&(e=(e%d.length+d.length)%d.length,d.splice(0,1,d.splice(e,1,d[0])[0]))},881018622,-1548952103,function(d,e,f,h,l,m,n){return d(l,m,n)},866181053,371641849,1746068208,\';""[}"\',-2037972368,function(d,e,f,h,l,m,n,p,q){return f(h,l,m,n,p,q)},866181053,-462051482,-1325213219,function(d,e){if(0!=e.length){d=(d%e.length+e.length)%e.length;var f=e[0];e[0]=e[d];e[d]=f}},-857794131,856038255,238705845,-680098610,-2071693591,-1548952103,function(d,e,f){var h=e.length;f.forEach(function(l,m,n){this.push(n[m]=e[(e.indexOf(l)-e.indexOf(this[m])+m+h--)%e.length])},d.split(""))},1222942195,function(d,e){e.push(d)},function(d){for(var e=d.length;e;)d.push(d.splice(--e,1)[0])},function(d,e,f,h,l,m){return e(h,l,m)},function(d,e){e=(e%d.length+d.length)%d.length;d.splice(e,1)},776226015,function(d,e){for(e=(e%d.length+d.length)%d.length;e--;)d.unshift(d.pop())},function(d,e,f,h,l){return e(f,h,l)},b,743083756,function(){for(var d=64,e=[];++d-e.length-32;){switch(d){case 58:d-=14;case 91:case 92:case 93:continue;case 123:d=47;case 94:case 95:case 96:continue;case 46:d=95}e.push(String.fromCharCode(d))}return e},1539732541,-83782463,573560636,1141639398,1133560316,-1732362723,981202616,444424391,929797469,function(){for(var d=64,e=[];++d-e.length-32;){switch(d){case 91:d=44;continue;case 123:d=65;break;case 65:d-=18;continue;case 58:d=96;continue;case 46:d=95}e.push(String.fromCharCode(d))}return e},null];c[4]=c;c[25]=c;c[87]=c;try{try{(-7==c[27]||(((0,c[38])(c[69*Math.pow(7,4)+-165653]),c[58])(c[22],c[9%Math.pow(4,3)- -65]),0))&&(0,c[73])((0,c[68])(c[40]),c[72],c[16],c[17]),-7!=c[20764-Math.pow(5,1)+-20678]&&(-6===c[80]?(0,c[20])(c[40],c[new Date("1969-12-31T18:31:11.000-05:30")/1E3]):(0,c[72])(c[40],c[50])),c[77]<=49+Math.pow(4,5)+-1083?(((0,c[65])(c[41],(0,c[2])(),c[74]),c[65])(c[250*Math.pow(2,4)-3959],(0,c[2])(),c[40]),(0,c[70])(c[74],c[new Date("1969-12-31T20:15:36.000-03:45")/1E3]),c[73])((0,c[72])(c[40],c[80]),c[65],c[41],(0,c[26])(),c[16]):(((0,c[72])(c[74],c[13]),c[73])((0,c[58])(c[61],c[40]),c[58],c[12],c[16]),c[68])(c[4])<=(0,c[78])(c[34],c[0]),-5!==c[87]&&(c[81]<15+Math.pow(6,4)-1321||((0,c[15])(c[62],c[57]),(0,c[3])(c[38],c[46]),0))&&((0,c[42])(c[87],c[2]),c[47])(c[71],(0,c[36])(),c[38])}catch(d){(0,c[67])(c[7],c[27]),(0,c[44])(c[38]),(0,c[47])(c[71],(0,c[26])(),c[38])*(0,c[-65*Math.pow(6,2)+2343])(c[19],c[80])}try{-3!==c[56]&&(-6===c[1]||((0,c[44])(c[38]),0))&&(0,c[67])(c[25],c[Math.pow(8,2)-2+13]),0<=c[23]&&(-2>=c[68]?((((0,c[13])(c[88-Math.pow(1,1)+-40],(0,c[39])((0,c[47])(c[71],(0,c[26])(),c[38]),c[44],c[38]),(0,c[47])(c[71],(0,c[86])(),c[7]),(((0,c[47])(c[71],(0,c[26])(),c[7]),c[47])(c[71],(0,c[86])(),c[-106+Math.pow(4,5)%220]),c[3])(c[7],c[50]),(0,c[44])(c[7]),c[new Date("1970-01-01T10:31:11.000+10:30")/1E3],(0,c[new Date("1969-12-31T23:01:26.000-01:00")/1E3])(),c[72]),c[3])(c[26+Math.pow(3,5)-231],c[73]),c[74])(c[24+289%Math.pow(3,1)]),c[43])((0,c[74])(c[87]),c[42],(0,c[39])((0,c[83])(c[28],c[25]),c[54],c[0],c[7]),c[7],c[48]):(0,c[58])((0,c[54])(c[33],c[72])>>>(0,c[39])(((0,c[39])((0,c[83])(c[70],c[87]),c[46],c[80]),(0,c[49])(c[2],c[12])),c[74],c[44],c[28]),((0,c[73])((0,c[77])((0,c[33])(c[81],c[8]),c[39],c[76]),c[43],(0,c[29])(c[45-23%Math.pow(3,4)],c[64]),c[64],c[60]),c[88])(c[new Date("1970-01-01T02:30:11.000+02:30")/1E3],c[65]),c[25],(0,c[25])((0,c[20])(c[45]),c[69],c[0],c[43]),c[2],c[22],c[53])%(0,c[2])(c[22],c[41]))}catch(d){((0,c[71])(c[6],(0,c[60])(),c[7]),c[71])(c[6],(0,c[21])(),c[62])}try{2!==c[75]&&(0,c[63])((0,c[29])(c[33],c[31]),c[64],c[22],c[79]),(0,c[new Date("1970-01-01T08:15:34.000+08:15")/1E3])((0,c[61])(c[20]),c[70],c[68])}catch(d){-10!=c[29]?(0,c[63])(c[205+Math.pow(4,5)+-1215],c[19])&(0,c[34])((0,c[Math.pow(6,5)+12045-19772])(c[81],c[14]),c[39],c[68]):((0,c[42])(c[67],(0,c[16])(),c[33]),c[34])((0,c[42])(c[67],(0,c[21])(),c[68]),c[70],c[33]),0!=c[17]&&(9>=c[62]?(0,c[59])(c[49],((((0,c[34])((0,c[34])((0,c[42])(c[67],(0,c[31])(),c[68]),c[37],c[14],c[89]),c[49],c[11],c[14]),c[38])((0,c[88])(c[33],c[32]),c[Math.pow(6,1)+4- -32],(0,c[37])(c[2],c[44]),c[67],(0,c[82])(),c[33]),c[49])(c[64],c[68]),c[70])(c[2]),(0,c[37])(c[33],c[13]),(0,c[88])(c[68],c[74]),c[65],c[33]):((0,c[34])((0,c[34])(((0,c[34])((0,c[52])(c[80],c[14]),c[80],c[82],c[24]),(0,c[29])(c[33],c[60]),c[73])(c[8],(0,c[62])(),c[33]),c[Math.pow(3,5)+-8588- -8349],c[33],c[34]),c[68],c[33],c[57]),((0,c[80])(c[3],c[24]),c[83])(c[48],c[64]),c[68])(c[33],c[78])&(0,c[65])((0,c[Math.pow(7,3)+134+-437])(c[61],c[45]),c[66],c[9],c[56])),0!=c[60]&&((0,c[4])(c[64],c[46]),"2")||(0,c[29])(c[33],c[53])}}catch(d){return"enhanced_except_gZgB_uf-_w8_"+a}return b.join("")}; blah blah after'; preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0); // Print the entire match result var_dump($matches);

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