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"
"
gmx

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"(?mx)^([0-2\s]?\d)[^\d]([0-6]\d)[^\d]([0-6]\d)\s?\={25,}\sList\sof\smods\s\={25,}\n(?P<mod_lines>(^([0-2\s]?\d)[^\d]([0-6]\d)[^\d]([0-6]\d)\s(?!\=).*\n)+)^([0-2\s]?\d)[^\d]([0-6]\d)[^\d]([0-6]\d)\s?\={25,}").unwrap(); let string = " 11:51:09 ============================================================================================= List of mods =============================================================================================== 11:51:09 modsReadOnly = true 11:51:09 safeModsActivated = false 11:51:09 customMods = true 11:51:09 hash = '06E03E1C463E72E69E7B56CB8BD8C7F859180514' 11:51:09 hashShort = 'f1973b83' 11:51:09 name | modDir | default | official | origin | hash | hashShort | fullPath 11:51:09 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 11:51:09 @ACECompatSOG | @ACECompatSOG | false | false | GAME DIR | 58c416e22842b40b72edf1dde9ddc97cb1f6667a | 75251e92 | C:\\TCAFiles\\Users\\Antistasi\\2433\\@ACECompatSOG 11:51:09 Gruppe Adler Trenches | @GruppeAdlerTrenches | false | false | GAME DIR | 1469bb9106e667d7257e5117e40516bea48b6001 | a300f1d0 | C:\\TCAFiles\\Users\\Antistasi\\2433\\@GruppeAdlerTrenches 11:51:09 VET_Unflipping - 1.3.2 | @VETUnflipping | false | false | GAME DIR | b87f16fa85a76c4522fe0fe67521f1ab4a7a7fb0 | dc68cef1 | C:\\TCAFiles\\Users\\Antistasi\\2433\\@VETUnflipping 11:51:09 @ZeusEnhancedACE3Compatibility | @ZeusEnhancedACE3Compatibility | false | false | GAME DIR | 3ba9d33273e6b3891df3e596d51295136f59ec40 | 5c267667 | C:\\TCAFiles\\Users\\Antistasi\\2433\\@ZeusEnhancedACE3Compatibility 11:51:09 Zeus Enhanced 1.12.2 | @ZeusEnhanced | false | false | GAME DIR | 6f138882698bd41e062699f5b0bcc1ea79468511 | 4eb0fe50 | C:\\TCAFiles\\Users\\Antistasi\\2433\\@ZeusEnhanced 11:51:09 TFAR | @TaskForceArrowheadRadioBETA | false | false | GAME DIR | 6e889b7a92591e469d9e037aa3631fb8e5a954fc | d11c0c7f | C:\\TCAFiles\\Users\\Antistasi\\2433\\@TaskForceArrowheadRadioBETA 11:51:09 Enhanced Movement | @EnhancedMovement | false | false | GAME DIR | fbc1f582c89f11919f9c6ead5d842e6c1aea9b71 | a47fddc8 | C:\\TCAFiles\\Users\\Antistasi\\2433\\@EnhancedMovement 11:51:09 Community Base Addons v3.15.8 | @CBAA3 | false | false | GAME DIR | 1d7bc59f1f4d1d2a3604e1c33be8fdd686a5617f | b09d9bc5 | C:\\TCAFiles\\Users\\Antistasi\\2433\\@CBAA3 11:51:09 Advanced Combat Environment 3.15.2 | @ace | false | false | GAME DIR | f5413c6e60e6aa9e5bbeda3f1dcdc3e029727f68 | 56cefafc | C:\\TCAFiles\\Users\\Antistasi\\2433\\@ace 11:51:09 [Dev] Antistasi - Community 2.6.1 | @Dev1AntistasiDevBuild | false | false | GAME DIR | 1c0cf6a7b0eaf2c81d3a479c327a5c1712e28070 | 19619fb8 | C:\\TCAFiles\\Users\\Antistasi\\2433\\@Dev1AntistasiDevBuild 11:51:09 Arma 3 Creator DLC: S.O.G. Prairie Fire | vn | false | true | GAME DIR | b086dbcc2986a92aef3b0fd6204c8bc54ee8a8d4 | f66fee82 | C:\\TCAFiles\\Users\\Antistasi\\2433\\vn 11:51:09 Arma 3 Art of War | aow | true | true | GAME DIR | 6ba7b160d357ca64590614f6a6c4579168efc1d0 | bc4189c2 | C:\\TCAFiles\\Users\\Antistasi\\2433\\aow 11:51:09 Arma 3 Contact (Platform) | enoch | true | true | GAME DIR | 9f6919562e719e9f70bf666194a7862d3274185a | 87e92527 | C:\\TCAFiles\\Users\\Antistasi\\2433\\enoch 11:51:09 Arma 3 Tanks | tank | true | true | GAME DIR | b4f3c4faa775f1c81c77f02f97cfa1aa18da5209 | bbdf79e2 | C:\\TCAFiles\\Users\\Antistasi\\2433\\tank 11:51:09 Arma 3 Tac-Ops | tacops | true | true | GAME DIR | 8fcf9c1f0a1fa5b8d354b64967ffd6583fc43d3e | fb047e5c | C:\\TCAFiles\\Users\\Antistasi\\2433\\tacops 11:51:09 Arma 3 Laws of War | orange | true | true | GAME DIR | 12abb4e3868e4b3036e9cea47138bdeb4abe518d | f564c92a | C:\\TCAFiles\\Users\\Antistasi\\2433\\orange 11:51:09 Arma 3 Malden | argo | true | true | GAME DIR | a844aa131096258aab8c000fddcc940284385494 | 49d733fb | C:\\TCAFiles\\Users\\Antistasi\\2433\\argo 11:51:09 Arma 3 Jets | jets | true | true | GAME DIR | 3f599a4f98ca3a0cd3c5e5e574acc16737c061ef | aae4f413 | C:\\TCAFiles\\Users\\Antistasi\\2433\\jets 11:51:09 Arma 3 Apex | expansion | true | true | GAME DIR | 26e79f13d9a9e6ae48a6119621f73d53cf411dbd | fe5acf19 | C:\\TCAFiles\\Users\\Antistasi\\2433\\expansion 11:51:09 Arma 3 Marksmen | mark | true | true | GAME DIR | 6f0fbfd365214eb67dc377503d2583c6718ff19b | 21bc50ea | C:\\TCAFiles\\Users\\Antistasi\\2433\\mark 11:51:09 Arma 3 Helicopters | heli | true | true | GAME DIR | f61b0de0ac2bd0602413e01b40b80f56b2b32130 | 5e3c056 | C:\\TCAFiles\\Users\\Antistasi\\2433\\heli 11:51:09 Arma 3 Karts | kart | true | true | GAME DIR | 952859b5e0bac3b093582ba87f54bdafea848df9 | e2ac0c1 | C:\\TCAFiles\\Users\\Antistasi\\2433\\kart 11:51:09 Arma 3 Zeus | curator | true | true | GAME DIR | 531b60d7d72729c65b0bb6a87f6cd48b6d6a7041 | 3cafe885 | C:\\TCAFiles\\Users\\Antistasi\\2433\\curator 11:51:09 Arma 3 | A3 | true | true | NOT FOUND (Empty) | | | 11:51:09 @TaskForceEnforcer | @TaskForceEnforcer | false | false | GAME DIR | da39a3ee5e6b4b0d3255bfef95601890afd80709 | 11fdd19c | C:\\TCAFiles\\Users\\Antistasi\\2433\\@TaskForceEnforcer 11:51:09 @utility | @utility | false | false | GAME DIR | da39a3ee5e6b4b0d3255bfef95601890afd80709 | 11fdd19c | C:\\TCAFiles\\Users\\Antistasi\\2433\\@utility 11:51:09 ====================================================================="; // 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/