Save & Share

  • Current Version: 6
  • Update Regex
    ctrl+⇧+s
  • Save new Regex
    ctrl+s
  • Add to 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

import re regex = re.compile(r"(?s)(\#\d{1,})(.*?)(\#\d{1,})", flags=re.MULTILINE) test_str = ("#0\n" "$dumpvars\n" "0!\n" "0\"\n" "0#\n" "bxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 7\n" "bxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 6\n" "bxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 5\n" "b0000000000000000 $\n" "bxxxxxxxxxxxxxxxx /\n" "bxxxxxxxxxxxxxxxx .\n" "bxxxxxxxxxxxxxxxx )\n" "b0111111111111111 %\n" "bxxxxxxxxxxxxxxxx 1\n" "bxxxxxxxxxxxxxxxx 0\n" "bxxxxxxxxxxxxxxxx *\n" "b10101010101010101010101010101010 &\n" "bxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +\n" "bxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ,\n" "bxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 2\n" "bxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -\n" "bxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 3\n" "bxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 4\n" "bxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (\n" "bxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx '\n" "$end\n" "#600\n" "1!\n" "b0000000000000000 )\n" "b0111111111111111 *\n" "b10101010101010101010101010101010 +\n" "b0000000000000000 /\n" "b0111111111111111 1\n" "b00000000000000000000000000000000 5\n" "b10101010101010101010101010101010 4\n" "b00000000000000000000000000000000 2\n" "b00000000000000000000000000000000 3\n" "b010101010101010101010101010101010 7\n" "#1200\n" "b0000010001010111 $\n" "b0111101110101000 %\n" "b10101100101001110100001001010001 &\n" "0!\n" "b10101010101010101010101010101010 ,\n" "b00000000000000000000000000000000 -\n" "#1800\n" "1!\n" "b0000010001010111 )\n" "b0111101110101000 *\n" "b10101100101001110100001001010001 +\n" "b010101010101010101010101010101010 (\n" "b010101010101010101010101010101010 '\n" "b0000010001010111 /\n" "b00000010001010110111101110101001 5\n" "b0111101110101000 1\n" "b00000010000110001010011000011000 5\n" "b10101100101001110100001001010001 4\n" "b010101100101001110100001001010001 7\n" "b00000010000110001010011000011000 2\n" "b00000010000110001010011000011000 3\n" "b010101110101111111110100001101001 7\n" "#2400\n" "b0000100010101110 $\n" "b0111011101010001 %\n" "b10101110101000111101100111111000 &\n" "0!\n" "b10101100101001110100001001010001 ,\n" "b00000010000110001010011000011000 -\n" "#3000\n" "1!\n" "b0000100010101110 )\n" "b0111011101010001 *\n" "b10101110101000111101100111111000 +\n" "b010101110101111111110100001101001 (\n" "b010101110101111111110100001101001 '\n" "b0000100010101110 /\n" "b00000100001100010100110000110000 5\n" "b0111011101010001 1\n" "b00000100000010111010000100001110 5\n" "b10101110101000111101100111111000 4\n" "b010110000101111001000000000010000 7\n" "b00000100000010111010000100001110 2\n" "b00000100000010111010000100001110 3\n" "b010110010101011110111101100000110 7\n" "#3600\n" "b0000110100000101 $\n" "b0111001011111010 %\n" "b10110000101000000111000110011111 &\n" "0!\n" "b10101110101000111101100111111000 ,\n" "b00000100000010111010000100001110 -\n" "#4200") matches = regex.finditer(test_str) for match_num, match in enumerate(matches, start=1): print(f"Match {match_num} was found at {match.start()}-{match.end()}: {match.group()}") for group_num, group in enumerate(match.groups(), start=1): print(f"Group {group_num} found at {match.start(group_num)}-{match.end(group_num)}: {group}")

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 Python, please visit: https://docs.python.org/3/library/re.html