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

/
/

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"Original title: (.*)").unwrap(); let string = " Conversation opened. 1 read message. Skip to content Using Animateka Mail with screen readers prints@animateka.si Search Click here to enable desktop notifications for Animateka Mail. Learn more Hide Mail COMPOSE Labels Inbox Starred Sent Mail Katja Smail Submissions More More 21 of 22 Print all In new window Prijavnica Inbox x website@animateka.si Jul 6 (3 days ago) to misak I apply with my film to the following competition programme:: CENTRAL AND EASTERN EUROPEAN COMPETITION SHORT ANIMATED FILMS Original title: Menagerie English title: Menagerie Running time: 03:28 Animation Technique: pencil and pen on paper Screening format: HD file Production year: 2014 Country: Canada Suitable for children: 0 Age group: 3 Original language: english / no dialogue Subtitles: no dialogue Producer: Vancouver Film School Distributer: Julian Gallese Director: Julian Gallese Name: Julian Gallese Script: Julian Gallese Address: 320 abbott street Design: Julian Gallese City: Vancouver Animation: Julian Gallese ZIP: V6B 2K9 Editing: Rob Wood Country: Canada Music: Lee Hutzulak Phone: 7788295169 Sound: Julian Gallese Email: juliangallese@gmail.com SHORT SYNOPSIS: A bird in the water is dreaming about a forest, an ocean liner and himself. Then the tide drifts him to a strange shore. SHORT BIOGRAPHY AND FILMOGRAPHY OF THE DIRECTOR: Julian is an artist born in 1992. The unknown is his recurrent theme. His work is a constant exploration of the subconscious. His drawings and storytelling brings up the absurd, in an approach that honours irrationality over technique. filmography: menagerie (2014), untitled (2014) Previous festival screenings and awards: - Escala humana, Des Pacio art gallery - Spike & Mike's festival of Animation - Athens Animfest '15 - Dum-D Student Animation Festival - Future Film Festival, Italy - Fest Anča International Animation Festival, Slovakia Selection preview copy of the film: 1 Online film submission: 1 Link: https://vimeo.com/115080765 I, the undersigned, acknowledge and agree:: 1, 1 By checking the option(s) bellow, I agree:: 1, 2, 3 I have read:: 1 --- http://www.animateka.si/2015/tl_files/upload/stillframe_lq.jpg http://www.animateka.si/2015/tl_files/upload/screenshot3.jpg http://www.animateka.si/2015/tl_files/upload/julian-6.jpg Click here to Reply, Reply to all, or Forward 0.08 GB (0%) of 15 GB used Manage Program Policies Powered by Google Last account activity: 27 minutes ago Details "; // result will be a tuple containing the start and end indices for the first match in the string let result = regex.captures(string); let (start, end) = match result { Some((s, e)) => (s, e), None => { // ... } }; println!("{}", &string[start, end]); }

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/