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
  • 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

/
/
gis

Test String

Code Generator

Generated Code

package main import ( "regexp" "fmt" ) func main() { var re = regexp.MustCompile(`(?is)^(?:[[:^print:][:cntrl:]\s]|GIF89.{0,20})*<\?(?:php)?\s*\/\/open\s*templates\/yours\.php.{0,180}?yourlinkscam.{0,100}?rand\(\d+,.{0,2500}?your\s*account\s*will\s*be\s*limited\s*over\s*24\s*h.{0,200}?unauthorised\s*account\s*access.{0,220}?Click\s*the\s*link\s*Below.{0,80}Confirm\s*Your\s*Account.{0,450}?paypal\s*inc\..{0,300}?paypal\s*corporation(?:[^;]+;\s*)?\s*if\(\!empty\(\$_GET\[["']view['"]\]\)\)\{echo\s*\$html(?:[^>]+>\s*)?$`) var str = `<?php //open templates/Yours.php with a text editor copy paste your html code in $html between the 2 ' and change all ' in your html to \' and href="http://yourlinkscam" to href="'.$var.'" ini_set("output_buffering",4096); $IDK = rand(00000000000, 99999999999).time(); error_reporting(0); $html=' <html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"> <style type="text/css">body { width: 100% !important;}</style> </head> <table width="0" border="0"> <tbody><tr> <td> <div> <table cellspacing="0" cellpadding="0" width="550" border="0"> <tbody> <tr> <td style=" BACKGROUND: #ffffff; LINE-HEIGHT: 22px;border-radius: 10px 10px 10px 10px"> <center><td> <div style="FONT-SIZE:14px;FONT-FAMILY:Arial;COLOR:#747474"> <p align="left"> </p><div style="FONT-SIZE:10px;FONT-FAMILY:Arial black;COLOR:#828282;padding-left:30px"> <center><p style="FONT-SIZE:28px"><strong><em><font color="#003084">P<span><font>a</font></span>y</font><font color="#0098db">Pal</font></em></strong></center> </p> </div> <p></p> </div> </td></center> </sub></font></p></div></p> </div> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </div> <div><table cellspacing="0" cellpadding="0" width="0" border="0"> <tbody> <tr> <td style=" BACKGROUND: #F3F3FF; ; LINE-HEIGHT: 22px"> <table cellspacing="0" cellpadding="0" width="600" align="left" border="0"> <tbody> <tr> <td> <div> <br /> <br /> <br /> <td style="PADDING-TOP:15px"> <div style="FONT-SIZE:15px;FONT-FAMILY:Arial;COLOR:#585858;margin-left:10px;margin-right:30px"> <center><p style="font-family:Helvetica Neue Light,Helvetica,Arial,sans-serif;font-size:20px;color:#009cde">Your Account will be limited over 24 h if you dont confirm it .</p></center> <br> <p> <strong>why my Account will Be limited ?</p></strong> <center><em><li><ins>unauthorised account access From 59.56.111.253 . China-CN</ins></em></p></li> <br> Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20100101 Firefox/10.0 <br> <br> <span style="color: #808080;"><strong>Click the link Below and login then follow steps to Confirm Your Account :</strong></span><br /><br /><br><a onclick="return true" href="'.$var.'" style="FONT-SIZE:14px;FONT-FAMILY:Arial;WIDTH:250px;COLOR:#fff;TEXT-ALIGN:center;DISPLAY:inline-block;BACKGROUND-COLOR:#16aeff;border-radius:7px;line-height:28px"><strong>Confirm My Account </strong> </a><br /> <br /> <br /> <br /> <span style="font-size: 10px; font-family: Arial, Verdena;"> <em>PayPal Inc. : PayPal Corporate Center, 100 North Tryon Street, Charlotte, NC 28255. <br/> <br/> You can un-subscribe to security alerts by configuring your online account. We are sending this email to provide support for your personal account. <br /> <br />&#169; 2017 PayPal Corporation. All rights reserved</em> </span> </li>'; if(!empty($_GET["view"])){echo $html;} ?>` for i, match := range re.FindAllString(str, -1) { fmt.Println(match, "found at index", i) } }

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 Golang, please visit: https://golang.org/pkg/regexp/