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

`
`
gmX

Test String

Code Generator

Generated Code

// include the latest version of the regex crate in your Cargo.toml extern crate regex; use regex::Regex; fn main() { let regex = Regex::new(r#"(?m)<td.*?class="namelinks".*?">(.+?)</a>"#).unwrap(); let string = "<tr> <td class=\"field_domain\"><a href=\"/goto/1/eboo74/2/\" target=\"_blank\" title=\"advocaciamdc.com\" class=\"namelinks\" id=\"linksdd-domaineboo74\">advocaciamdc.com</a><ul id=\"links-domaineboo74\" class=\"kmenucontent\" style=\"display:none;\"><li class=\"first\"><a href=\"/goto/16/eg4d59/2/\" target=\"_blank\" class=\"favicons favgodaddy\" title=\"Register at GoDaddy.com\">GoDaddy.com</a></li><li><a href=\"/goto/53/ee87fh/2/\" target=\"_blank\" class=\"favicons favdynadot\" title=\"Register at Dynadot.com\">Dynadot.com</a></li><li><a href=\"/goto/43/eecp19/2/\" target=\"_blank\" class=\"favicons favnamecheap\" title=\"Register at Namecheap.com\">Namecheap.com</a></li></ul></td> <td class=\"field_watchlist\"><span class=\"wl\" id=\"wl-2-eboo74\"></span></td> <td class=\"field_length\">12</td> <td class=\"field_bl\"><a href=\"/goto/34/ebdukr/2/\" target=\"_blank\" class=\"bllinks\" title=\"0\" id=\"backlinks-bleboo74\">0</a><ul id=\"links-bleboo74\" class=\"kmenucontent\" style=\"display:none;\"><li class=\"first\"><a href=\"/goto/34/ebdukr/2/\" target=\"_blank\" class=\"favicons favmajestic\" title=\"Check Backlinks on Majestic.com\">Majestic.com</a></li><li class=\"seperator\">&nbsp;</li><li><a href=\"/goto/28/eg64b8/2/\" target=\"_blank\" class=\"favicons favseokicks\" title=\"Check Backlinks on SEOkicks.de\">SEOkicks.de</a></li><li><a href=\"/goto/56/ed1td8/2/\" target=\"_blank\" class=\"favicons favsemrush\" title=\"Check Backlinks on SEMRush.com\">SEMRush.com</a></li><li><a href=\"/goto/27/ecwtfo/2/\" target=\"_blank\" class=\"favicons favsearchm\" title=\"Searchmetrics\">Searchmetrics</a></li></ul></td> <td class=\"field_domainpop\"><a href=\"/goto/28/eg64b8/2/\" target=\"_blank\" title=\"0\">0</a></td> <td class=\"field_creationdate\"><a href=\"/goto/8/edemrz/2/\" target=\"_blank\" title=\"Whois Creation Date: 2019-08-06\">2019</a></td> <td class=\"field_abirth\">-</td> <td class=\"field_aentries\"><a href=\"/goto/6/eddzzf/2/\" target=\"_blank\" title=\"0 saved crawl results\">0</a></td> <td class=\"field_alexa\"><a href=\"/goto/4/eddwsg/2/\" target=\"_blank\" title=\"0\" class=\"\">0</a></td> <td class=\"field_majestic_globalrank\"><a href=\"/goto/34/ebdukr/2/\" target=\"_blank\">0</a></td> <td class=\"field_dmoz\">-</td> <td class=\"field_statustld_registered\"><a href=\"/domain/advocaciamdc.com#namestatus\" target=\"_blank\">0</a></td> <td class=\"field_statuscom\"><a href=\"/goto/18/efli0j/2/?tld=com\" target=\"_blank\" class=\"sprite stlds stld22c\" title=\".com available\"><span>available</span></a></td> <td class=\"field_statusnet\"><a href=\"/goto/18/efli0j/2/?tld=net\" target=\"_blank\" class=\"sprite stlds stld22c\" title=\".net available\"><span>available</span></a></td> <td class=\"field_statusorg\"><a href=\"/goto/18/efli0j/2/?tld=org\" target=\"_blank\" class=\"sprite stlds stld22c\" title=\".org available\"><span>available</span></a></td> <td class=\"field_statusbiz\"><a href=\"/goto/18/efli0j/2/?tld=biz\" target=\"_blank\" class=\"sprite stlds stld22c\" title=\".biz available\"><span>available</span></a></td> <td class=\"field_statusinfo\"><a href=\"/goto/18/efli0j/2/?tld=info\" target=\"_blank\" class=\"sprite stlds stld22c\" title=\".info available\"><span>available</span></a></td> <td class=\"field_statusde\"><a href=\"/goto/18/efli0j/2/?tld=de\" target=\"_blank\" class=\"sprite stlds stld22c\" title=\".de available\"><span>available</span></a></td> <td class=\"field_adddate\">2020-10-25</td> <td class=\"field_related_cnobi\">-</td> <td class=\"field_wikipedia_links\">-</td> <td class=\"field_changes\">Yesterday 18:55</td> <td class=\"field_whois\"><a href=\"/goto/1/eboo74/2/\" target=\"_blank\" title=\"Register now\" class=\"status_free\">available</a></td> <td class=\"field_relatedlinks\"><a class=\"sprite sicon smenu domainlinks\" href=\"#\" id=\"expiredcom-eboo74\" title=\"Related Links (click here for menu)\"><span>RL</span></a><ul id=\"links-eboo74\" class=\"kmenucontent\" style=\"display:none;\"><li class=\"first\"><a href=\"/goto/16/eg4d59/2/\" target=\"_blank\" class=\"favicons favgodaddy\" title=\"Register at GoDaddy.com\">GoDaddy.com</a></li><li><a href=\"/goto/53/ee87fh/2/\" target=\"_blank\" class=\"favicons favdynadot\" title=\"Register at Dynadot.com\">Dynadot.com</a></li><li><a href=\"/goto/43/eecp19/2/\" target=\"_blank\" class=\"favicons favnamecheap\" title=\"Register at Namecheap.com\">Namecheap.com</a></li><li class=\"seperator\">&nbsp;</li><li><a href=\"/domain/advocaciamdc.com\" class=\"favicons favhomepage\" target=\"_blank\" title=\"Domain Details on ExpiredDomains.net\">Domain Details</a></li><li><a href=\"/goto/116/ebesj8/2/\" target=\"_blank\" class=\"favicons favgodaddy\" title=\"GoDaddy.com Appraisal\">GoDaddy Appraisal</a></li><li><a href=\"/goto/25/eep3go/2/\" target=\"_blank\" class=\"favicons favsemrush\" title=\"Check Rankings on SEMRush.com\">SEMRush</a></li><li><a href=\"/goto/93/eb1rfr/2/\" target=\"_blank\" class=\"favicons favtrademarkia\" title=\"Check Domain Name on Trademarkia\">Trademarkia</a></li><li><a href=\"/goto/7/ec5uh7/2/\" target=\"_blank\" class=\"favicons favgoogle\" title=\"Google the Domain Name\">Google Name</a></li><li><a href=\"/goto/11/eekeoy/2/\" target=\"_blank\" class=\"favicons favgoogle\" title=\"Google info:domain.tld\">Google Info</a></li><li><a href=\"/goto/15/ef6qyy/2/\" target=\"_blank\" class=\"favicons favgoogle\" title=\"Google site:domain.tld\">Google Site</a></li><li><a href=\"/goto/6/eddzzf/2/\" target=\"_blank\" class=\"favicons favarchiveorg\" title=\"Check Website in Wayback Machine\">Wayback Machine</a></li><li><a href=\"/goto/9/ebbfv1/2/\" target=\"_blank\" class=\"favicons favhomepage\" title=\"Visit the Website\">Visit Domain</a></li><li><a href=\"/goto/8/edemrz/2/\" target=\"_blank\" class=\"favicons favwhois\" title=\"Whois Domain\">Whois Domain</a></li><li><a href=\"/goto/21/ecqo3m/2/\" target=\"_blank\" class=\"favicons favdomaintools\" title=\"Check Domainhistory on Domaintools.com\">Domaintools.com</a></li></ul></td> </tr>"; // result will be an iterator over tuples containing the start and end indices for each match in the string let result = regex.captures_iter(string); for mat in result { println!("{:?}", mat); } }

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 Rust, please visit: https://docs.rs/regex/latest/regex/