Regular Expressions 101

Save & Share

  • Regex Version: ver. 27
  • 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

/
/
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)^ # 40-character hex values are okay (0x[a-fA-F\d]{40}(*ACCEPT) # 'D' or 'X' followed by 33 specific characters are okay |D[^0-4\W_IOV-Z][^\W_IOl0]{32}(*ACCEPT) |X[^\W_IOl0]{33}(*ACCEPT) # 'bc1' followed by a range of specific characters are okay |bc1[^\W_IO]{25,39}(*ACCEPT) # Anything else is NOT okay, and all remaining processing should stop |(*COMMIT)[13][^\W_IOl0]{33} )").unwrap(); let string = "0x7309f0134f3e51e8Cbe29dd86068e0f264f6c946 0x7a250d5630b4cf539739df2c5dacb4c659f2488d 0x6b1b45c925b29ea9d5bdde5490d7016edd288700 0x61765fc9f4e67612d53f29b31484D9e95cc3bdb3 0xD9cfbf343ac0eec25f5e2ead383fb4d57aaafbf9 0x870205573906a3122f3647d34775FF77cb33f90e 0x2dddae5c2c27ae6c1751cac72adacfe82a60f8a4 0xab06b7806eac2329c5585ddd08dd7fe4e13dde5d bc1q3xe5n0j3qnsqc045e2vfx0246qzq5nyzag35xv bc1qjw2g03cdnwcxh8gwfcypd3hu3s3md3aqe8zvrl bc1qrupduyqlh4r5627vyz46fxker6wrf0sqt7he24 bc1qyemk24czaa6a2nr89nrz775wefg32d 17PZUMBg3gaPZvzC6jD4RMYT6J7D8ByzGa 1FMTSe43cKHTpR6r5xqEuE76hnFBkToGjY 35cydMA2G5i52XiM1wJ4EZf12fHdJ8hegQ 3PdD6TiMAdF34JieBgMSGAEFTMsHvQLBLC DBs4WcRE7eysKwRxHNX88XZVCQ9M6QSUSz DTkv31pUBjJUVrD34mAWf8Cp9BgEkUtNPM DDTtqnuZ5kfRT5qh2c7sNtqrJmV3iXYdGG DGottmgfevJzhhfmvGdA2JpMjMJ1DsSKjJ D9a1Ah7mUNAJwNqHPER4DN9zNLoqcYFDZW D5zikmZbvK6ReZSFPDVGusqP3qKcJTjo4r DLCDJhnh6aGotar6b182jpzbNEyXb3C361 D61T1GVeMZM8UHvXKyyD55Ur9efAF2mb5f XtbJQV8RWC39gMYsVdbRMCwMBDTAYPP99R Xi7CnDniGd726iY4pQr79PTqWtZuVDGu8g XxXhd59h44sRdvT3h5t2WXatox8Jhng9ob XnjYnC83zC9VAAkf1hg7yPEHJrd3vJwR2d XoCccXGPj16WZPzzD3UjsXRTPySZsAAXVD Xh77YHy84s2mrsAWZftY1oZNZUakPHyL35 XuixmDKiB1fPzamnLoZw9Km3Lk7e2CyRT1 XbJvzQQCWxLNkRUeFq4nS5FQhwT1LWVXJh bc1qyemk24czaa6a2nr89nrz775w 1x870205573906a3122f3647d34775ff77cb33f90e Ox2dddae5c2c27ae6c1751cac72adacfe82a60f8a4 0xab06bg806eac2329c5585ddd08dd7fe4e13dde5d 0xD9cfbf343AC0eec25f5e_ead383fb4d57aaafbf9 bclq3xe5n0j3qnsqc045e2vfx0246qzq5nyzag35xv bc1yemk24czaa6a2nr89nrz775wvptxg57yIe750ut 0xab06b7806eac2329c5585ddd08dd7fe4 25cydMA2G5i52XiM1wJ4EZf12fHdJ8hegQ 3PdD6TIMAdF34JieBgMSGAEFTMsHvQLBLC lFMTSe43cKHTpR6r5xqEuE76hnFBkT0GjY 12GFUMBg3gaPZOzC6lD4RMYT6J7D8ByzGa DI1T1GVeMZM8UHvXKyyD55Ur9efAF2mb5f D4JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ D41T1GVeMZM8UHvXKyyD55Ur9efAF2mb5f D1zikmZbvK6ReZSFPDVGusqP3qKcJTjo4r DOTtqnuZ5kfRs5qh2c7sNtqrJmV3iXYdff DLCDJhnh6aGotar6b182jpzbNEyXb3C36l XoGGGXGPj06WZPzzD3UjsXRTPySZsAAXVD Xh66YHy22s2mrsAWZftYIoZNZUakPXYdff XuixmDKiBlfPzamnLoZw9Km3Lk7e2CyRT1 XBBBBBBCCCCCCRUeFq4nS5F0hwT1LLLLLh bc1qemk24czaa6a2nr89nrz775w "; // 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/