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
No Match

r"
"
gm

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)^\$(?P<guid>[\w\d-]+).(.|\n)(?P<nome>.+)..(?P<url>https://[\w\-\.\/]+)..(?P<desc>\w.*)\(.+$").unwrap(); let string = "$1cb07348-34a4-4741-b50f-c41e584370f7TeamSpeak Addon AuthorVhttps://badges-content.teamspeak.com/1cb07348-34a4-4741-b50f-c41e584370f7/addon_author\"Creator of TeamSpeak Addons(ß”Â0· $50bbdbc8-0f2a-46eb-9808-602225b49627 Gamescom 2016Whttps://badges-content.teamspeak.com/50bbdbc8-0f2a-46eb-9808-602225b49627/gamescom_2016\"Registered during Gamescom 2016(ß”Â0Î $d95f9901-c42d-4bac-8849-7164fd9e2310Paris Games Week 2016^https://badges-content.teamspeak.com/d95f9901-c42d-4bac-8849-7164fd9e2310/paris_gamesweek_2016\"'Registered during Paris Games Week 2016(ß”Â0³ $62444179-0d99-42ba-a45c-c6b1557d079a Gamescom 2014Whttps://badges-content.teamspeak.com/62444179-0d99-42ba-a45c-c6b1557d079a/gamescom_2014\"Registered at Gamescom 2014(뿞Æ0Ê $fa3ece28-64df-431f-b1b3-90844bfdd2d9Paris Games Week 2014^https://badges-content.teamspeak.com/fa3ece28-64df-431f-b1b3-90844bfdd2d9/paris_gamesweek_2014\"#Registered at Paris Games Week 2014(뿞Æ0Ø $450f81c1-ab41-4211-a338-222fa94ed157\"TeamSpeak Addon Developer (Bronze)]https://badges-content.teamspeak.com/450f81c1-ab41-4211-a338-222fa94ed157/addon_author_bronze\"%Creator of at least 1 TeamSpeak Addon(œ­òÆ0Ù $c9e97536-5a2d-4c8e-a135-af404587a472\"TeamSpeak Addon Developer (Silver)]https://badges-content.teamspeak.com/c9e97536-5a2d-4c8e-a135-af404587a472/addon_author_silver\"&Creator of at least 3 TeamSpeak Addons(œ­òÆ0Õ $94ec66de-5940-4e38-b002-970df0cf6c94 TeamSpeak Addon Developer (Gold)[https://badges-content.teamspeak.com/94ec66de-5940-4e38-b002-970df0cf6c94/addon_author_gold\"&Creator of at least 5 TeamSpeak Addons(œ­òÆ0º $534c9582-ab02-4267-aec6-2d94361daa2a Gamescom 2017Whttps://badges-content.teamspeak.com/534c9582-ab02-4267-aec6-2d94361daa2a/gamescom_2017\"\"Visited TeamSpeak at Gamescom 2017(;µÌ0µ $34dbfa8f-bd27-494c-aa08-a312fc0bb240Gamescom Hero 2017Shttps://badges-content.teamspeak.com/34dbfa8f-bd27-494c-aa08-a312fc0bb240/hero_2017\"Gaming Hero at Gamescom 2017(;µÌ0¦"; // 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/