Regular Expressions 101

Save & Manage Regex

  • Current Version: 1
  • Save & Share
  • 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
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 = @"\{\s*\""MapObject((?!MapObject)[\s\S])+\""Type\""\s*:\s*\""moReference(?:Point|Line)ID\""((?!MapObject)[\s\S])+},?\s*"; string input = @"[ { ""MapObject"" : { ""BoundingBox"" : [ -1313.574, -1010.804, -1113.574, -810.804 ], ""Caption"" : ""Ref46"", ""Comment"" : "", ""Position"" : { ""CPosition"" : [ -1213.574, -910.804, 0, 0 ] }, ""Size"" : { ""CPosition"" : [ 100, 100, 0, 0 ] }, ""Type"" : ""moReferencePointID"" } }, { ""MapObject"" : { ""BoundingBox"" : [ -1313.06, 495.39, -1113.06, 695.39 ], ""Caption"" : ""Ref47"", ""Comment"" : "", ""Position"" : { ""CPosition"" : [ -1213.06, 595.39, 0, 0 ] }, ""Size"" : { ""CPosition"" : [ 100, 100, 0, 0 ] }, ""Type"" : ""moReferencePointID"" } }, { ""MapObject"" : { ""BoundingBox"" : [ -18070, 1180, -17870, 1380 ], ""Caption"" : ""Path way84"", ""Comment"" : "", ""ExecutableMapObject"" : { ""BehaviourList"" : [ { ""Speed"" : 200, ""Type"" : ""bcSpeed"" }, { ""AvoidanceSpeed"" : 150, ""FailureAction"" : 0, ""FailureRetries"" : 60, ""FailureWait"" : 10, ""PathMode"" : 2, ""PerSegment"" : 15, ""ReturnToStart"" : 0, ""ScanAngle"" : 0.06981317007977778, ""Type"" : ""bcObstacleAvoidance"", ""Wait"" : 10, ""WaitUnits"" : 2 }, { ""BinarySensorStates"" : 3, ""SensorSensitivityList"" : [ { ""IgnoreMapData"" : false, ""Mask"" : 65536, ""SpeedCapDistance"" : 70, ""SpeedCapEnabled"" : true, ""StopDistance"" : 70 }, { ""IgnoreMapData"" : false, ""Mask"" : 131072, ""SpeedCapDistance"" : 70, ""SpeedCapEnabled"" : true, ""StopDistance"" : 70 }, { ""IgnoreMapData"" : false, ""Mask"" : 262144, ""SpeedCapDistance"" : 240, ""SpeedCapEnabled"" : true, ""StopDistance"" : 240 }, { ""IgnoreMapData"" : false, ""Mask"" : 524288, ""SpeedCapDistance"" : 240, ""SpeedCapEnabled"" : true, ""StopDistance"" : 240 }, { ""IgnoreMapData"" : false, ""Mask"" : 1048576, ""SpeedCapDistance"" : 240, ""SpeedCapEnabled"" : true, ""StopDistance"" : 240 }, { ""IgnoreMapData"" : false, ""Mask"" : 2097152, ""SpeedCapDistance"" : 280, ""SpeedCapEnabled"" : true, ""StopDistance"" : 280 }, { ""IgnoreMapData"" : false, ""Mask"" : 4194304, ""SpeedCapDistance"" : 320, ""SpeedCapEnabled"" : true, ""StopDistance"" : 320 }, { ""IgnoreMapData"" : false, ""Mask"" : 8388608, ""SpeedCapDistance"" : 0, ""SpeedCapEnabled"" : false, ""StopDistance"" : 0 }, { ""IgnoreMapData"" : false, ""Mask"" : 16777216, ""SpeedCapDistance"" : 0, ""SpeedCapEnabled"" : false, ""StopDistance"" : 0 } ], ""SpeedCap"" : 30, ""Type"" : ""bcObstacleSensitivity2"" } ], ""EntryPoint"" : { ""CPosition"" : [ -13450, 1290, 0, 0 ] }, ""ExitPoint"" : { ""CPosition"" : [ -17970, 1280, 0, 0 ] }, ""RelocateOnExecute"" : false, ""Required"" : false, ""TwoWay"" : false }, ""GoalSet"" : [ { ""Path"" : { ""PathType"" : ""pitLinear"", ""Segments"" : [ { ""Segment"" : [ -13450, 1290, -17970, 1280 ] } ] } } ], ""Position"" : { ""CPosition"" : [ -17970, 1280, 0, 0 ] }, ""Size"" : { ""CPosition"" : [ 0, 0, 0, 0 ] }, ""Type"" : ""moLinePathID"" } }, { ""MapObject"" : { ""AttributeList"" : [ [ ""Lock"", ""{} LabInt {}"" ] ], ""BoundingBox"" : [ -12350, -500, -12150, -300 ], ""Caption"" : ""QUEUE/LabInt"", ""Comment"" : "", ""ExecutableMapObject"" : { ""EntryPoint"" : { ""CPosition"" : [ -12250, -400, 0, 0 ] }, ""ExitPoint"" : { ""CPosition"" : [ -12250, -400, 0, 0 ] }, ""RelocateOnExecute"" : false, ""Required"" : false, ""TwoWay"" : false }, ""Position"" : { ""CPosition"" : [ -12250, -400, 0, 0 ] }, ""Size"" : { ""CPosition"" : [ 100, 100, 0, 0 ] }, ""Type"" : ""moHotPointID"" } }, ]"; foreach (Match m in Regex.Matches(input, pattern)) { 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