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
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
  • Match everything enclosed
    (?:...)
  • Capture everything enclosed
    (...)
  • 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

Substitution

Processing...

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#"(\S{1,2})(:")(['a-z]*)(",)"#).unwrap(); let string = "あ:\"a\",い:\"i\",う:\"u\",え:\"e\",お:\"o\",ゔぁ:\"va\",ゔぃ:\"vi\",ゔ:\"vu\",ゔぇ:\"ve\",ゔぉ:\"vo\",か:\"ka\",き:\"ki\",きゃ:\"kya\",きぃ:\"kyi\",きゅ:\"kyu\",く:\"ku\",け:\"ke\",こ:\"ko\",が:\"ga\",ぎ:\"gi\",ぐ:\"gu\",げ:\"ge\",ご:\"go\",ぎゃ:\"gya\",ぎぃ:\"gyi\",ぎゅ:\"gyu\",ぎぇ:\"gye\",ぎょ:\"gyo\",さ:\"sa\",す:\"su\",せ:\"se\",そ:\"so\",ざ:\"za\",ず:\"zu\",ぜ:\"ze\",ぞ:\"zo\",し:\"shi\",しゃ:\"sha\",しゅ:\"shu\",しょ:\"sho\",じ:\"ji\",じゃ:\"ja\",じゅ:\"ju\",じょ:\"jo\",た:\"ta\",ち:\"chi\",ちゃ:\"cha\",ちゅ:\"chu\",ちょ:\"cho\",つ:\"tsu\",て:\"te\",と:\"to\",だ:\"da\",ぢ:\"di\",づ:\"du\",で:\"de\",ど:\"do\",な:\"na\",に:\"ni\",にゃ:\"nya\",にゅ:\"nyu\",にょ:\"nyo\",ぬ:\"nu\",ね:\"ne\",の:\"no\",は:\"ha\",ひ:\"hi\",ふ:\"fu\",へ:\"he\",ほ:\"ho\",ひゃ:\"hya\",ひゅ:\"hyu\",ひょ:\"hyo\",ふぁ:\"fa\",ふぃ:\"fi\",ふぇ:\"fe\",ふぉ:\"fo\",ば:\"ba\",び:\"bi\",ぶ:\"bu\",べ:\"be\",ぼ:\"bo\",びゃ:\"bya\",びゅ:\"byu\",びょ:\"byo\",ぱ:\"pa\",ぴ:\"pi\",ぷ:\"pu\",ぺ:\"pe\",ぽ:\"po\",ぴゃ:\"pya\",ぴゅ:\"pyu\",ぴょ:\"pyo\",ま:\"ma\",み:\"mi\",む:\"mu\",め:\"me\",も:\"mo\",みゃ:\"mya\",みゅ:\"myu\",みょ:\"myo\",や:\"ya\",ゆ:\"yu\",よ:\"yo\",ら:\"ra\",り:\"ri\",る:\"ru\",れ:\"re\",ろ:\"ro\",りゃ:\"rya\",りゅ:\"ryu\",りょ:\"ryo\",わ:\"wa\",を:\"wo\",ん:\"n\",ゐ:\"wi\",ゑ:\"we\",きぇ:\"kye\",きょ:\"kyo\",じぃ:\"jyi\",じぇ:\"jye\",ちぃ:\"cyi\",ちぇ:\"che\",ひぃ:\"hyi\",ひぇ:\"hye\",びぃ:\"byi\",びぇ:\"bye\",ぴぃ:\"pyi\",ぴぇ:\"pye\",みぇ:\"mye\",みぃ:\"myi\",りぃ:\"ryi\",りぇ:\"rye\",にぃ:\"nyi\",にぇ:\"nye\",しぃ:\"syi\",しぇ:\"she\",いぇ:\"ye\",うぁ:\"wha\",うぉ:\"who\",うぃ:\"wi\",うぇ:\"we\",ゔゃ:\"vya\",ゔゅ:\"vyu\",ゔょ:\"vyo\",すぁ:\"swa\",すぃ:\"swi\",すぅ:\"swu\",すぇ:\"swe\",すぉ:\"swo\",くゃ:\"qya\",くゅ:\"qyu\",くょ:\"qyo\",くぁ:\"qwa\",くぃ:\"qwi\",くぅ:\"qwu\",くぇ:\"qwe\",くぉ:\"qwo\",ぐぁ:\"gwa\",ぐぃ:\"gwi\",ぐぅ:\"gwu\",ぐぇ:\"gwe\",ぐぉ:\"gwo\",つぁ:\"tsa\",つぃ:\"tsi\",つぇ:\"tse\",つぉ:\"tso\",てゃ:\"tha\",てぃ:\"thi\",てゅ:\"thu\",てぇ:\"the\",てょ:\"tho\",とぁ:\"twa\",とぃ:\"twi\",とぅ:\"twu\",とぇ:\"twe\",とぉ:\"two\",ぢゃ:\"dya\",ぢぃ:\"dyi\",ぢゅ:\"dyu\",ぢぇ:\"dye\",ぢょ:\"dyo\",でゃ:\"dha\",でぃ:\"dhi\",でゅ:\"dhu\",でぇ:\"dhe\",でょ:\"dho\",どぁ:\"dwa\",どぃ:\"dwi\",どぅ:\"dwu\",どぇ:\"dwe\",どぉ:\"dwo\",ふぅ:\"fwu\",ふゃ:\"fya\",ふゅ:\"fyu\",ふょ:\"fyo\",ぁ:\"a\",ぃ:\"i\",ぇ:\"e\",ぅ:\"u\",ぉ:\"o\",ゃ:\"ya\",ゅ:\"yu\",ょ:\"yo\",っ:\"\",ゕ:\"ka\",ゖ:\"ka\",ゎ:\"wa\",\" \":\" \",んあ:\"n'a\",んい:\"n'i\",んう:\"n'u\",んえ:\"n'e\",んお:\"n'o\",んや:\"n'ya\",んゆ:\"n'yu\",んよ:\"n'yo\","; let substitution = ":*:\\3::\\1\\n"; // result will be a String with the substituted value let result = regex.replace_all(string, substitution); println!("{}", result); }

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/