Regular Expressions 101

Save & Share

  • Regex Version: ver. 1
  • 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
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)[0-9]{2}:(([1-9][0-9])|(0[1-9]))").unwrap(); let string = "'00:00', '00:05', '00:15', '00:20', '00:25', '00:30', '00:35', '00:40', '00:45', '00:50', '00:55', '01:00', '01:05', '01:10', '01:15', '01:20', '01:40', '01:45', '01:55', '02:05', '02:10', '02:15', '02:35', '02:40', '02:45', '02:55', '03:05', '03:10', '03:30', '03:55', '04:00', '04:05', '04:25', '04:40', '04:55', '05:00', '05:05', '05:15', '05:20', '05:25', '05:30', '05:35', '05:50', '05:55', '06:05', '06:20', '06:25', '06:30', '06:35', '06:45', '06:50', '07:05', '07:15', '07:30', '07:40', '07:45', '07:50', '07:55', '08:10', '08:20', '08:25', '08:40', '08:45', '08:50', '09:15', '09:20', '09:45', '09:50', '09:55', '10:10', '10:15', '10:25', '10:30', '10:45', '10:50', '11:00', '11:05', '11:15', '11:25', '11:35', '11:45', '11:50', '11:55', '12:00', '12:10', '12:15', '12:25', '12:50', '12:55', '13:00', '13:40', '13:45', '13:50', '14:00', '14:10', '14:20', '14:35', '14:55', '15:05', '15:10', '15:15', '15:20', '15:25', '15:45', '15:55', '16:10', '16:15', '16:20', '16:25', '16:35', '16:45', '16:50', '16:55', '17:05', '17:30', '17:35', '17:45', '17:50', '18:00', '18:05', '18:10', '18:15', '18:20', '18:30', '18:35', '18:45', '19:00', '19:10', '19:20', '19:40', '19:50', '20:00', '20:15', '20:20', '20:35', '20:45', '20:55', '21:00', '21:05', '21:15', '21:20', '21:25', '21:30', '21:40', '21:45', '22:00', '22:10', '22:15', '22:25', '22:40', '22:45', '22:50', '22:55'"; // 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/