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