Regular Expressions 101

Save & Share

  • Regex Version: ver. 3
  • 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

/
/
g

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"\(\w+:\w+\)").unwrap(); let string = "['OncoMed Pharmaceuticals Inc. (OMED:NASDAQ)', ' , a company \"we\\'ve had a long-term passion for.\" He considers OncoMed a \"leader in the cancer stem cell space,\" with a number of clinical assets including a handful that are proprietary, and many partnered with larger-cap pharmas and biotechs. Among the candidates slated for either clinical trials or data readouts in 2017 is demcizumab, in pancreatic cancer. \"We think it will be a key catalyst for the shares,\" King said. Other assets include tarextumab, for a small cell lung cancer; DLL4/VEG4, also in non-small cell lung cancer; and \"a new asset that was previously known as I/O#2. . .a very highly validated immuno-oncology target called TIGIT,\" in development in partnership with Celgene Corp. (CELG:NASDAQ).'] ['King called Syndax Pharmaceuticals Inc. (SNDX:NASDAQ) \"a hybrid story. \" The company is a player in the immuno-oncology space as well as in the \"broader\" cancer world with a drug called entinostat, which is in Phase 3 in metastatic breast cancer. Readouts on overall survival aren\\'t expected until 2019, but King is \"optimistic about Syndax\\'s chances for success in the Phase 3 trial.\" The company is also in collaborations with major pharmas in the \"immune checkpoint space,\" with data expected to \"roll out over the course of 2017.\"'] ['Syros Pharmaceuticals (SYRS:NASDAQ) is an early-stage company, with a ~$250M market cap, that King considers a leader in gene regulation, with a concept called super-enhancers. The company both develops its \"own internal candidates to some of the highly validated targets,\" as well as repurposes assets that may have been abandoned for indications like blood disorders. Syros might be \"a quiet story the first half of 2017, but I think in the second half of 2017, we\\'ll start to see some firewor"; // 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/