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

/
/
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#"aria-label="(\d{1,3})""#).unwrap(); let string = "<div style=\"position: absolute; left: 0px; top: 0px; z-index: 106; width: 100%;\"><span id=\"1754CFBC-3135-4AAF-B4AB-197E77AD840A\" style=\"display: none;\">Możesz się poruszać przy użyciu klawiszy strzałek.</span><div style=\"width: 36px; height: 37px; overflow: hidden; position: absolute; cursor: pointer; touch-action: none; left: -69px; top: 110px; z-index: 1;\" title=\"\" aria-label=\"2255\" role=\"button\" tabindex=\"0\" aria-describedby=\"1754CFBC-3135-4AAF-B4AB-197E77AD840A\"><img alt=\"\" src=\"https://maps.gstatic.com/mapfiles/transparent.png\" draggable=\"false\" style=\"width: 36px; height: 37px; user-select: none; border: 0px; padding: 0px; margin: 0px; max-width: none;\"></div><div style=\"width: 36px; height: 37px; overflow: hidden; position: absolute; cursor: pointer; touch-action: none; left: 13px; top: -50px; z-index: 1;\" title=\"\" aria-label=\"1530\" role=\"button\" tabindex=\"-1\" aria-describedby=\"1754CFBC-3135-4AAF-B4AB-197E77AD840A\"><img alt=\"\" src=\"https://maps.gstatic.com/mapfiles/transparent.png\" draggable=\"false\" style=\"width: 36px; height: 37px; user-select: none; border: 0px; padding: 0px; margin: 0px; max-width: none;\"></div><div style=\"width: 36px; height: 37px; overflow: hidden; position: absolute; cursor: pointer; touch-action: none; left: -12px; top: 122px; z-index: 1;\" title=\"\" aria-label=\"1392\" role=\"button\" tabindex=\"-1\" aria-describedby=\"1754CFBC-3135-4AAF-B4AB-197E77AD840A\"><img alt=\"\" src=\"https://maps.gstatic.com/mapfiles/transparent.png\" draggable=\"false\" style=\"width: 36px; height: 37px; user-select: none; border: 0px; padding: 0px; margin: 0px; max-width: none;\"></div><div style=\"width: 36px; height: 37px; overflow: hidden; position: absolute; cursor: pointer; touch-action: none; left: -140px; top: 29px; z-index: 1;\" title=\"\" aria-label=\"1136\" role=\"button\" tabindex=\"-1\" aria-describedby=\"1754CFBC-3135-4AAF-B4AB-197E77AD840A\"><img alt=\"\" src=\"https://maps.gstatic.com/mapfiles/transparent.png\" draggable=\"false\" style=\"width: 36px; height: 37px; user-select: none; border: 0px; padding: 0px; margin: 0px; max-width: none;\"></div><div style=\"width: 36px; height: 37px; overflow: hidden; position: absolute; cursor: pointer; touch-action: none; left: -139px; top: -74px; z-index: 1;\" title=\"\" aria-label=\"1121\" role=\"button\" tabindex=\"-1\" aria-describedby=\"1754CFBC-3135-4AAF-B4AB-197E77AD840A\"><img alt=\"\" src=\"https://maps.gstatic.com/mapfiles/transparent.png\" draggable=\"false\" style=\"width: 36px; height: 37px; user-select: none; border: 0px; padding: 0px; margin: 0px; max-width: none;\"></div><div style=\"width: 36px; height: 37px; overflow: hidden; position: absolute; cursor: pointer; touch-action: none; left: -60px; top: 15px; z-index: 1;\" title=\"\" aria-label=\"1056\" role=\"button\" tabindex=\"-1\" aria-describedby=\"1754CFBC-3135-4AAF-B4AB-197E77AD840A\"><img alt=\"\" src=\"https://maps.gstatic.com/mapfiles/transparent.png\" draggable=\"false\" style=\"width: 36px; height: 37px; user-select: none; border: 0px; padding: 0px; margin: 0px; max-width: none;\"></div><div style=\"width: 36px; height: 37px; overflow: hidden; position: absolute; cursor: pointer; touch-action: none; left: -82px; top: -195px; z-index: 1;\" title=\"\" aria-label=\"919\" role=\"button\" tabindex=\"-1\" aria-describedby=\"1754CFBC-3135-4AAF-B4AB-197E77AD840A\"><img alt=\"\" src=\"https://maps.gstatic.com/mapfiles/transparent.png\" draggable=\"false\" style=\"width: 36px; height: 37px; user-select: none; border: 0px; padding: 0px; margin: 0px; max-width: none;\"></div><div style=\"width: 36px; height: 37px; overflow: hidden; position: absolute; cursor: pointer; touch-action: none; left: -198px; top: 23px; z-index: 1;\" title=\"\" aria-label=\"878\" role=\"button\" tabindex=\"-1\" aria-describedby=\"1754CFBC-3135-4AAF-B4AB-197E77AD840A\"><img alt=\"\" src=\"https://maps.gstatic.com/mapfiles/transparent.png\" draggable=\"false\" style=\"width: 36px; height: 37px; user-select: none; border: 0px; padding: 0px; margin: 0px; max-width: none;\"></div><div style=\"width: 36px; height: 37px; overflow: hidden; position: absolute; cursor: pointer; touch-action: none; left: 60px; top: 117px; z-index: 1;\" title=\"\" aria-label=\"730\" role=\"button\" tabindex=\"-1\" aria-describedby=\"1754CFBC-3135-4AAF-B4AB-197E77AD840A\"><img alt=\"\" src=\"https://maps.gstatic.com/mapfiles/transparent.png\" draggable=\"false\" style=\"width: 36px; height: 37px; user-select: none; border: 0px; padding: 0px; margin: 0px; max-width: none;\"></div><div style=\"width: 36px; height: 37px; overflow: hidden; position: absolute; cursor: pointer; touch-action: none; left: 46px; top: -58px; z-index: 1;\" title=\"\" aria-label=\"705\" role=\"button\" tabindex=\"-1\" aria-describedby=\"1754CFBC-3135-4AAF-B4AB-197E77AD840A\"><img alt=\"\" src=\"https://maps.gstatic.com/mapfiles/transparent.png\" draggable=\"false\" style=\"width: 36px; height: 37px; user-select: none; border: 0px; padding: 0px; margin: 0px; max-width: none;\"></div><div style=\"width: 36px; height: 37px; overflow: hidden; position: absolute; cursor: pointer; touch-action: none; left: -185px; top: -64px; z-index: 1;\" title=\"\" aria-label=\"633\" role=\"button\" tabindex=\"-1\" aria-describedby=\"1754CFBC-3135-4AAF-B4AB-197E77AD840A\"><img alt=\"\" src=\"https://maps.gstatic.com/mapfiles/transparent.png\" draggable=\"false\" style=\"width: 36px; height: 37px; user-select: none; border: 0px; padding: 0px; margin: 0px; max-width: none;\"></div><div style=\"width: 36px; height: 37px; overflow: hidden; position: absolute; cursor: pointer; touch-action: none; left: -2px; top: 25px; z-index: 1;\" title=\"\" aria-label=\"590\" role=\"button\" tabindex=\"-1\" aria-describedby=\"1754CFBC-3135-4AAF-B4AB-197E77AD840A\"><img alt=\"\" src=\"https://maps.gstatic.com/mapfiles/transparent.png\" draggable=\"false\" style=\"width: 36px; height: 37px; user-select: none; border: 0px; padding: 0px; margin: 0px; max-width: none;\"></div><div style=\"width: 36px; height: 37px; overflow: hidden; position: absolute; cursor: pointer; touch-action: none; left: -72px; top: -84px; z-index: 1;\" title=\"\" aria-label=\"557\" role=\"button\" tabindex=\"-1\" aria-describedby=\"1754CFBC-3135-4AAF-B4AB-197E77AD840A\"><img alt=\"\" src=\"https://maps.gstatic.com/mapfiles/transparent.png\" draggable=\"false\" style=\"width: 36px; height: 37px; user-select: none; border: 0px; padding: 0px; margin: 0px; max-width: none;\"></div><div style=\"width: 36px; height: 37px; overflow: hidden; position: absolute; cursor: pointer; touch-action: none; left: 56px; top: 21px; z-index: 1;\" title=\"\" aria-label=\"524\" role=\"button\" tabindex=\"-1\" aria-describedby=\"1754CFBC-3135-4AAF-B4AB-197E77AD840A\"><img alt=\"\" src=\"https://maps.gstatic.com/mapfiles/transparent.png\" draggable=\"false\" style=\"width: 36px; height: 37px; user-select: none; border: 0px; padding: 0px; margin: 0px; max-width: none;\"></div><div style=\"width: 36px; height: 37px; overflow: hidden; position: absolute; cursor: pointer; touch-action: none; left: 108px; top: 29px; z-index: 1;\" title=\"\" aria-label=\"419\" role=\"button\" tabindex=\"-1\" aria-describedby=\"1754CFBC-3135-4AAF-B4AB-197E77AD840A\"><img alt=\"\" src=\"https://maps.gstatic.com/mapfiles/transparent.png\" draggable=\"false\" style=\"width: 36px; height: 37px; user-select: none; border: 0px; padding: 0px; margin: 0px; max-width: none;\"></div><div style=\"width: 36px; height: 37px; overflow: hidden; position: absolute; cursor: pointer; touch-action: none; left: -256px; top: -100px; z-index: 1;\" title=\"\" aria-label=\"408\" role=\"button\" tabindex=\"-1\" aria-describedby=\"1754CFBC-3135-4AAF-B4AB-197E77AD840A\"><img alt=\"\" src=\"https://maps.gstatic.com/mapfiles/transparent.png\" draggable=\"false\" style=\"width: 36px; height: 37px; user-select: none; border: 0px; padding: 0px; margin: 0px; max-width: none;\"></div><div style=\"width: 36px; height: 37px; overflow: hidden; position: absolute; cursor: pointer; touch-action: none; left: -128px; top: -192px; z-index: 1;\" title=\"\" aria-label=\"319\" role=\"button\" tabindex=\"-1\" aria-describedby=\"1754CFBC-3135-4AAF-B4AB-197E77AD840A\"><img alt=\"\" src=\"https://maps.gstatic.com/mapfiles/transparent.png\" draggable=\"false\" style=\"width: 36px; height: 37px; user-select: none; border: 0px; padding: 0px; margin: 0px; max-width: none;\"></div><div style=\"width: 36px; height: 37px; overflow: hidden; position: absolute; cursor: pointer; touch-action: none; left: 120px; top: -97px; z-index: 1;\" title=\"\" aria-label=\"313\" role=\"button\" tabindex=\"-1\" aria-describedby=\"1754CFBC-3135-4AAF-B4AB-197E77AD840A\"><img alt=\"\" src=\"https://maps.gstatic.com/mapfiles/transparent.png\" draggable=\"false\" style=\"width: 36px; height: 37px; user-select: none; border: 0px; padding: 0px; margin: 0px; max-width: none;\"></div><div style=\"width: 36px; height: 37px; overflow: hidden; position: absolute; cursor: pointer; touch-action: none; left: -121px; top: 93px; z-index: 1;\" title=\"\" aria-label=\"250\" role=\"button\" tabindex=\"-1\" aria-describedby=\"1754CFBC-3135-4AAF-B4AB-197E77AD840A\"><img alt=\"\" src=\"https://maps.gstatic.com/mapfiles/transparent.png\" draggable=\"false\" style=\"width: 36px; height: 37px; user-select: none; border: 0px; padding: 0px; margin: 0px; max-width: none;\"></div><div style=\"width: 36px; height: 37px; overflow: hidden; position: absolute; cursor: pointer; touch-action: none; left: -6px; top: -166px; z-index: 1;\" title=\"\" aria-label=\"243\" role=\"button\" tabindex=\"-1\" aria-describedby=\"1754CFBC-3135-4AAF-B4AB-197E77AD840A\"><img alt=\"\" src=\"https://maps.gstatic.com/mapfiles/transparent.png\" draggable=\"false\" style=\"width: 36px; height: 37px; user-select: none; border: 0px; padding: 0px; margin: 0px; max-width: none;\"></div><div style=\"width: 36px; height: 37px; overflow: hidden; position: absolute; cursor: pointer; touch-action: none; left: -198px; top: -179px; z-index: 1;\" title=\"\" aria-label=\"238\" role=\"button\" tabindex=\"-1\" aria-describedby=\"1754CFBC-3135-4AAF-B4AB-197E77AD840A\"><img alt=\"\" src=\"https://maps.gstatic.com/mapfiles/transparent.png\" draggable=\"false\" style=\"width: 36px; height: 37px; user-select: none; border: 0px; padding: 0px; margin: 0px; max-width: none;\"></div><div style=\"width: 36px; height: 37px; overflow: hidden; position: absolute; cursor: pointer; touch-action: none; left: -263px; top: -150px; z-index: 1;\" title=\"\" aria-label=\"197\" role=\"button\" tabindex=\"-1\" aria-describedby=\"1754CFBC-3135-4AAF-B4AB-197E77AD840A\"><img alt=\"\" src=\"https://maps.gstatic.com/mapfiles/transparent.png\" draggable=\"false\" style=\"width: 36px; height: 37px; user-select: none; border: 0px; padding: 0px; margin: 0px; max-width: none;\"></div><div style=\"width: 36px; height: 37px; overflow: hidden; position: absolute; cursor: pointer; touch-action: none; left: -243px; top: 13px; z-index: 1;\" title=\"\" aria-label=\"195\" role=\"button\" tabindex=\"-1\" aria-describedby=\"1754CFBC-3135-4AAF-B4AB-197E77AD840A\"><img alt=\"\" src=\"https://maps.gstatic.com/mapfiles/transparent.png\" draggable=\"false\" style=\"width: 36px; height: 37px; user-select: none; border: 0px; padding: 0px; margin: 0px; max-width: none;\"></div><div style=\"width: 36px; height: 37px; overflow: hidden; position: absolute; cursor: pointer; touch-action: none; left: 109px; top: 108px; z-index: 1;\" title=\"\" aria-label=\"148\" role=\"button\" tabindex=\"-1\" aria-describedby=\"1754CFBC-3135-4AAF-B4AB-197E77AD840A\"><img alt=\"\" src=\"https://maps.gstatic.com/mapfiles/transparent.png\" draggable=\"false\" style=\"width: 36px; height: 37px; user-select: none; border: 0px; padding: 0px; margin: 0px; max-width: none;\"></div><div style=\"width: 36px; height: 37px; overflow: hidden; position: absolute; cursor: pointer; touch-action: none; left: 64px; top: -168px; z-index: 1;\" title=\"\" aria-label=\"128\" role=\"button\" tabindex=\"-1\" aria-describedby=\"1754CFBC-3135-4AAF-B4AB-197E77AD840A\"><img alt=\"\" src=\"https://maps.gstatic.com/mapfiles/transparent.png\" draggable=\"false\" style=\"width: 36px; height: 37px; user-select: none; border: 0px; padding: 0px; margin: 0px; max-width: none;\"></div><div style=\"width: 36px; height: 37px; overflow: hidden; position: absolute; cursor: pointer; touch-action: none; left: 113px; top: -174px; z-index: 1;\" title=\"\" aria-label=\"76\" role=\"button\" tabindex=\"-1\" aria-describedby=\"1754CFBC-3135-4AAF-B4AB-197E77AD840A\"><img alt=\"\" src=\"https://maps.gstatic.com/mapfiles/transparent.png\" draggable=\"false\" style=\"width: 36px; height: 37px; user-select: none; border: 0px; padding: 0px; margin: 0px; max-width: none;\"></div><div style=\"width: 36px; height: 37px; overflow: hidden; position: absolute; cursor: pointer; touch-action: none; left: -177px; top: 86px; z-index: 1;\" title=\"\" aria-label=\"71\" role=\"button\" tabindex=\"-1\" aria-describedby=\"1754CFBC-3135-4AAF-B4AB-197E77AD840A\"><img alt=\"\" src=\"https://maps.gstatic.com/mapfiles/transparent.png\" draggable=\"false\" style=\"width: 36px; height: 37px; user-select: none; border: 0px; padding: 0px; margin: 0px; max-width: none;\"></div><div style=\"width: 36px; height: 37px; overflow: hidden; position: absolute; cursor: pointer; touch-action: none; left: 83px; top: 174px; z-index: 1;\" title=\"\" aria-label=\"1\" role=\"button\" tabindex=\"-1\" aria-describedby=\"1754CFBC-3135-4AAF-B4AB-197E77AD840A\"><img alt=\"\" src=\"https://maps.gstatic.com/mapfiles/transparent.png\" draggable=\"false\" style=\"width: 36px; height: 37px; user-select: none; border: 0px; padding: 0px; margin: 0px; max-width: none;\"></div></div>"; // 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/