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

@"
"
gm

Test String

Substitution

Processing...

Code Generator

Generated Code

using System; using System.Text.RegularExpressions; public class Example { public static void Main() { string pattern = @"(?<=^[0-9]{14}_).+(?=_)"; string substitution = @"$0"; string input = @"20231025041306_LLLLL_Aaaaaaaaaa_7777d4cb-6666631f-fa38-473e-a650-d3564505a2075.xls 20231025041406_LLLLL_Aaaaaaaaaa_8777befd-87765c3e-3164-4800-b102-a82d48aaaa52.xlsx 20231025041436_LLLLL_Aaaaaaaaaa_73d2bbbc.PDF 20231025041518_LLLLL_Aaaaaaaaaa_210zzz2c.csv 20231025041613_LLLLL_Aaaaaaaaaa_aqqqq1ad.txt 20231025041906_cccc_dddddd_rrrrrr_a6fff0d3.xls 20231025041935_cccc_dddddd_rrrrrr_f37ggg89.pdf 20231025042000_cccc_dddddd_rrrrrr_9e812343.csv 20231025042026_cccc_dddddd_rrrrrr_d7522280.txt 20231025042229_LllllAaaaaaaa_OO_OoooTttt_37gggd7-5e81ffhgedc77-4c8e-9fbc-d2996ggg0df1.xls 20231025042254_LllllAaaaaaaa_OO_OoooTttt_4fjjjfrgb-e3ec7993-92d7-4ab8-ad9e-83ejjjjj929b.xlsx 20231025042329_LllllAaaaaaaa_OO_OoooTttt_c0fkkkkf2.pdf 20231025042410_LllllAaaaaaaa_OO_OoooTttt_b555tefd7f.csv 20231025042505_LllllAaaaaaaa_OO_OoooTttt_9784g07e.txt 20231025042747_Ppppp_Rrrrr_Rrrrrr_2902e487-cc3c6chhhh074-4a2e-a97f-bfa0000a062e.xls 20231025042813_Ppppp_Rrrrr_Rrrrrr_aab84122-2fzzzz68-a706-49a5-a3ef-40030ffff0a3.xlsx 20231025042842_Ppppp_Rrrrr_Rrrrrr_79cdgggd2.PDF 20231025042923_Ppppp_Rrrrr_Rrrrrr_f07yyya8f.csv 20231025043220_Tttt_Dddddd_Rrrrrr_2444gr18d-13b4fb14-8fc2-45e0-b18b-59jkh6353d78.xlsx "; RegexOptions options = RegexOptions.Multiline; Regex regex = new Regex(pattern, options); string result = regex.Replace(input, substitution); } }

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 C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx