Regular Expressions 101

Save & Share

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

using System; using System.Text.RegularExpressions; public class Example { public static void Main() { string pattern = @"^((\.{2}\\)+|(\.?\\)?).+[^:\r\n]$"; string input = @"Directories: \\Reports\Test\\Test ..\meeting_minutes ..\..\profile Reports\2023\summary \Reports\2023\summary .\Reports\2023\summary ..\Projects\project_a ..\Projects\project a ..\Projects\..\.\project\.\..\a .\my_file ..\Music#a\file ..\Music[Genre]\file ..\Music(Genre)\file ..\Music-Hardcore-Metal\file ..\Documents\My+File ..\Documents\Some{Document} ..\Files\Afilewithweird;Characters'` ..\Music#^@!()-+{};',.`~a\file . ..\ ..\.. ..\..\ \\Reports\Test\\Test ..\..\Final .\..\Test .\..\Test\ ..\..\.\Final\..\Shapefiles\.\Landuse ..\..\.\Final\..\Shapefiles\.\Landuse\ ..\..\data ./data-files/geological/EQs_last_week_of_2021.csv../data-files/geological/ EQs_last_week_of_2021.csv../../data-files/EQs_last_week_of_2021.csv../../../data-files/ media\🎵 music\lo-fi & chill\set_03 (remastered) ..\..\data\[raw]_input_🧪\test-sample(01) src\core.modules\engine@v4 docs\2025_06\📝meeting_notes (draft)\summary docs\2025_06\📝meeting_notes (draft)\summary\ Files\ Files EQs_last_week_of_2021.csv../../../data-files/geological/EQs_last_week_of_2021 ../pictures/file .\temp\[backup]_2024\final-version (2) assets\images\new.logo-2025_v2\icon@2x#1 ..\users\username\Documents (Archived)\plan[final] projects\#active-clients\ACME_Corp\Q2 Report\summary v1.3\ config\env-settings\!urgent media\🎵 music\lo-fi & chill\set_03 (remastered) ..\..\data\[raw]_input_🧪\test-sample(01) src\core.modules\engine@v4 docs\2025_06\meeting_notes (draft)\📝summary_notes themes\🌑 darkmode (beta)\style-final! ..\..\logs\🪵 log-archive\2023-12-25Christmas ..\..\logs\🪵 log-archive\2023-12-25[Christmas] ..\..\logs\🪵 log-archive\2023-12-25 [Christmas] downloads\zips\patch_update v34-final! build\#output$\v2.1.1\installer(64bit) components\UI-Toolkit_🔥\modaldialog scripts\batch jobs\cleanup-temp_files! resources\📁 static\fonts\Roboto_Bold-Italic tests\[integration]_suite#2\test-case(01) temp\$$merge_conflict\attempt_#3\resolved✅ locales\en-US\messages(v1 backup\[legacy]_configs\1999 src\modules\@internal\storage-handler ..\releases\build#2025.06.14\installer-vFinal app\#dev[tools]\init Files: ..\users\username\Documents (Archived)\plan[final]\theplan.txt projects\#active-clients\ACME_Corp\Q2 Report\summary v1.3\summary.txt config\env-settings\!urgent\OVERVIEW.XLSX media\🎵 music\lo-fi & chill\set_03 (remastered)\Cool Song.mp3 ..\..\data\[raw]_input_🧪\test-sample(01)\Sample.db src\core.modules\engine@v4\engine.exe docs\2025_06\meeting_notes (draft)\📝summary_notes.txt themes\🌑 darkmode (beta)\style-final!.update build\#output$\v2.1.1\installer(64bit)\install_x64.msi resources\📁 static\fonts\Roboto_Bold-Italic.ttf "; RegexOptions options = RegexOptions.Multiline; foreach (Match m in Regex.Matches(input, pattern, options)) { Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index); } } }

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