Regular Expressions 101

Save & Manage Regex

  • Current Version: 1
  • Save & Share
  • Community Library

Flavor

  • PCRE2 (PHP)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java
  • .NET 7.0 (C#)
  • Rust
  • PCRE (Legacy)
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests
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
Processing...

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)^pin "([^"]*)".* #.*@(\d+\.\d+\.\d+(?:[^\s]*)).*$"#).unwrap(); let string = "# Pin npm packages by running ./bin/importmap pin \"application\", preload: true pin \"@hotwired/turbo-rails\", to: \"turbo.min.js\", preload: true pin \"@hotwired/stimulus\", to: \"https://ga.jspm.io/npm:@hotwired/stimulus@3.0.1/dist/stimulus.js\" pin \"@hotwired/stimulus-loading\", to: \"stimulus-loading.js\", preload: true pin_all_from \"app/javascript/controllers\", under: \"controllers\" pin \"react\", to: \"https://ga.jspm.io/npm:react@16.0.0/index.js\" pin \"object-assign\" # @4.1.1 pin \"glob-parent\", to: \"https://ga.jspm.io/npm:glob-parent@3.1.0/index.js\" pin \"is-extglob\", to: \"https://ga.jspm.io/npm:is-extglob@2.1.1/index.js\" pin \"is-glob\", to: \"https://ga.jspm.io/npm:is-glob@3.1.0/index.js\" pin \"os\", to: \"https://ga.jspm.io/npm:@jspm/core@2.0.0-beta.18/nodelibs/browser/os.js\" pin \"path\", to: \"https://ga.jspm.io/npm:@jspm/core@2.0.0-beta.19/nodelibs/browser/path.js\" pin \"path-dirname\", to: \"https://ga.jspm.io/npm:path-dirname@1.0.2/index.js\" pin \"process\", to: \"https://ga.jspm.io/npm:@jspm/core@2.0.0-beta.19/nodelibs/browser/process-production.js\" pin \"util\", to: \"https://ga.jspm.io/npm:@jspm/core@2.0.0-beta.2/nodelibs/browser/util.js\" pin \"assastimulus\", to: \"https://ga.jspm.io/npm:stimulus@2.0.0/dist/stimulus.umd.js\" pin \"stimulus\", to: \"https://ga.jspm.io/npm:stimulus@2.0.0/dist/stimulus.umd.js\" pin \"lodash\" # @4.17.1 a comment pin \"@github/hotkey\", to: \"@github--hotkey.js\" # @2.0.0 pin \"is-svg\", to: \"https://ga.jspm.io/npm:is-svg@3.0.0/index.js\" pin \"buffer\", to: \"https://ga.jspm.io/npm:@jspm/core@2.0.0-beta.19/nodelibs/browser/buffer.js\" pin \"html-comment-regex\", to: \"https://ga.jspm.io/npm:html-comment-regex@1.1.2/index.js\" pin \"nth-check\", to: \"https://ga.jspm.io/npm:nth-check@1.0.0/index.js\" pin \"boolbase\", to: \"https://ga.jspm.io/npm:boolbase@1.0.0/index.js\" pin \"jquery\", to: \"https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.js\" pin \"angularjs\", to: \"https://unpkg.com/angularjs@0.0.1/index.js\" pin \"angular\", to: \"https://unpkg.com/angular@1.8.2/index.js\" pin \"@angular/cli\", to: \"https://unpkg.com/@angular/cli@13.2.5/lib/cli/index.js\" pin \"underscore\" # a comment @1.13.2 "; // 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/