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

/
/
g

Test String

Code Generator

Generated Code

$re = '/<tr[^>]*>[^<]*<td[^>]*>(?<No>[^<]*)<[^>]*>[^>]*>(?<ID_dist>[^<]*)<\/td>[^>]*>(?<Jmeno>[^<]*)<\/td>[^>]*>(?<Tel_Home>[^<]*)<\/td>[^>]*>(?<Tel_Buss>[^<]*)<\/td>[^>]*>(?<Tel_mob>[^<]*)<\/td>[^>]*>(?<Country>[^<]*)<\/td>[^>]*><a[^>]*>(?<Email>[^<]*)[^<]*<\/a>[^<]*<\/td>[^>]*>(?<Levels>[^<]*)<\/td>[^>]*>(?<Pozice>[^<]*)<\/td>[^>]*>(?<Sponzor_ID>[^<]*)<\/td>/'; $str = ' <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>PBC - Distributors to be Renewed List</title> <meta name="description" content="Lifestyles PBC is an on-line tool to help our Distributors manage their business and achieve their goals." /> <meta name="keywords" content="Lifestyles, Lifestyles International, Personal Business Center, PBC"/> <link href="css/en.css" rel="stylesheet" type="text/css" /> </head> <body bgcolor="#EAF4D1" leftmargin="0" topmargin="3" marginwidth="0" marginheight="0"> <table border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#999999"> <tr> <td height="33" colspan="11" align="center" bgcolor="#FFFFFF"><h2 style="margin: 10px">Distributors to be Renewed List</h2> <p style="margin: 10px">Month: Nov. 2017</p></td> </tr> <tr> <td height="27" align="center" bgcolor="#CCCCCC"><strong>No.</strong></td> <td height="27" align="center" bgcolor="#CCCCCC"><strong>ID</strong></td> <td height="27" align="center" bgcolor="#CCCCCC"><strong>Name</strong></td> <td align="center" bgcolor="#CCCCCC"><strong>Home Phone</strong></td> <td align="center" bgcolor="#CCCCCC"><strong>Business Phone</strong></td> <td align="center" bgcolor="#CCCCCC"><strong>Cell Phone</strong></td> <td align="center" bgcolor="#CCCCCC"><strong>Country</strong></td> <td align="center" bgcolor="#CCCCCC"><strong>Email</strong></td> <td align="center" bgcolor="#CCCCCC"><strong>Levels</strong></td> <td align="center" bgcolor="#CCCCCC"><strong>Rank</strong></td> <td align="center" bgcolor="#CCCCCC"><strong>Sponsor</strong></td> </tr> <tr> <td height="27" align="center" bgcolor="#FFFFFF">1</td> <td height="27" align="center" bgcolor="#FFFFFF">98000204732</td> <td height="27" align="center" bgcolor="#FFFFFF">Pavel Kaleta</td> <td align="center" bgcolor="#FFFFFF">420 773512280</td> <td align="center" bgcolor="#FFFFFF"></td> <td align="center" bgcolor="#FFFFFF"></td> <td align="center" bgcolor="#FFFFFF">Czech Republic</td> <td align="center" bgcolor="#FFFFFF"><a href="mailto:"></a></td> <td align="center" bgcolor="#FFFFFF">19</td> <td align="center" bgcolor="#FFFFFF">Distributor</td> <td align="center" bgcolor="#FFFFFF">80011630542</td> </tr> <tr> <td height="27" align="center" bgcolor="#FFFFFF">2</td> <td height="27" align="center" bgcolor="#FFFFFF">98000229140</td> <td height="27" align="center" bgcolor="#FFFFFF">Ivana Bilkova</td> <td align="center" bgcolor="#FFFFFF">420 605934970</td> <td align="center" bgcolor="#FFFFFF"></td> <td align="center" bgcolor="#FFFFFF"></td> <td align="center" bgcolor="#FFFFFF">Czech Republic</td> <td align="center" bgcolor="#FFFFFF"><a href="mailto:ifcabilkova@seznam.cz">ifcabilkova@seznam.cz</a></td> <td align="center" bgcolor="#FFFFFF">20</td> <td align="center" bgcolor="#FFFFFF">Distributor</td> <td align="center" bgcolor="#FFFFFF">98000142059</td> </tr> <tr> <td height="27" align="center" bgcolor="#FFFFFF">3</td> <td height="27" align="center" bgcolor="#FFFFFF">98000229289</td> <td height="27" align="center" bgcolor="#FFFFFF">Martina Vitkovska</td> <td align="center" bgcolor="#FFFFFF">420 606629784</td> <td align="center" bgcolor="#FFFFFF"></td> <td align="center" bgcolor="#FFFFFF"></td> <td align="center" bgcolor="#FFFFFF">Czech Republic</td> <td align="center" bgcolor="#FFFFFF"><a href="mailto:martinavitkovska@seznam.cz">martinavitkovska@seznam.cz</a></td> <td align="center" bgcolor="#FFFFFF">18</td> <td align="center" bgcolor="#FFFFFF">Distributor</td> <td align="center" bgcolor="#FFFFFF">13980242</td> </tr> <tr> <td height="27" align="center" bgcolor="#FFFFFF">4</td> <td height="27" align="center" bgcolor="#FFFFFF">98000253035</td> <td height="27" align="center" bgcolor="#FFFFFF">Lenka Lovetinska</td> <td align="center" bgcolor="#FFFFFF">420 60598685</td> <td align="center" bgcolor="#FFFFFF">420 567223836</td> <td align="center" bgcolor="#FFFFFF"></td> <td align="center" bgcolor="#FFFFFF">Czech Republic</td> <td align="center" bgcolor="#FFFFFF"><a href="mailto:lovetinskal@seznam.cz">lovetinskal@seznam.cz</a></td> <td align="center" bgcolor="#FFFFFF">20</td> <td align="center" bgcolor="#FFFFFF">Distributor</td> <td align="center" bgcolor="#FFFFFF">98000142059</td> </tr> <tr> <td height="27" align="center" bgcolor="#FFFFFF">5</td> <td height="27" align="center" bgcolor="#FFFFFF">98000253463</td> <td height="27" align="center" bgcolor="#FFFFFF">Filip Korda</td> <td align="center" bgcolor="#FFFFFF">421 902483141</td> <td align="center" bgcolor="#FFFFFF">421 948186144</td> <td align="center" bgcolor="#FFFFFF"></td> <td align="center" bgcolor="#FFFFFF">Slovak Republic</td> <td align="center" bgcolor="#FFFFFF"><a href="mailto:korda@sanusvita.sk">korda@sanusvita.sk</a></td> <td align="center" bgcolor="#FFFFFF">20</td> <td align="center" bgcolor="#FFFFFF">Distributor</td> <td align="center" bgcolor="#FFFFFF">80011633242</td> </tr> <tr> <td height="27" align="center" bgcolor="#FFFFFF">6</td> <td height="27" align="center" bgcolor="#FFFFFF">CZ-03-04277</td> <td height="27" align="center" bgcolor="#FFFFFF">Olga Kostomarova</td> <td align="center" bgcolor="#FFFFFF">420 603160599</td> <td align="center" bgcolor="#FFFFFF"></td> <td align="center" bgcolor="#FFFFFF"></td> <td align="center" bgcolor="#FFFFFF">Czech Republic</td> <td align="center" bgcolor="#FFFFFF"><a href="mailto:"></a></td> <td align="center" bgcolor="#FFFFFF">19</td> <td align="center" bgcolor="#FFFFFF">Distributor</td> <td align="center" bgcolor="#FFFFFF">80011630542</td> </tr> </table> </body> </html> <script>window.focus()</script> '; 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