|
@@ -0,0 +1,74 @@
|
|
|
+#!meta
|
|
|
+
|
|
|
+{"kernelInfo":{"defaultKernelName":"csharp","items":[{"aliases":[],"name":"csharp"}]}}
|
|
|
+
|
|
|
+#!csharp
|
|
|
+
|
|
|
+string sml = @"<L
|
|
|
+ <L
|
|
|
+ <A Hello World >
|
|
|
+ >
|
|
|
+>.";
|
|
|
+
|
|
|
+#!csharp
|
|
|
+
|
|
|
+string smls = @"<L
|
|
|
+ <L
|
|
|
+ <A Hello World >
|
|
|
+ >
|
|
|
+>.
|
|
|
+<L
|
|
|
+ <L
|
|
|
+ <A Greeting >
|
|
|
+ >
|
|
|
+>.
|
|
|
+";
|
|
|
+
|
|
|
+#!csharp
|
|
|
+
|
|
|
+using System.Text.RegularExpressions;
|
|
|
+
|
|
|
+string input = "baaabaaaaabababaa";
|
|
|
+string pattern = @"(?=a{3,})a+";
|
|
|
+
|
|
|
+Match match = Regex.Match(input, pattern);
|
|
|
+
|
|
|
+while (match.Success) {
|
|
|
+ Console.WriteLine($"index {match.Index} - value {match.Value.ToString()}");
|
|
|
+ match = match.NextMatch();
|
|
|
+}
|
|
|
+Regex.Replace(input, pattern, "+").Display();
|
|
|
+
|
|
|
+#!csharp
|
|
|
+
|
|
|
+#!set --name test --value @csharp:sml
|
|
|
+using System.Text.RegularExpressions;
|
|
|
+
|
|
|
+Regex regex = new Regex(@"(\<)(?<content>.*)(\>)(\.?)");
|
|
|
+Match match = regex.Match(test);
|
|
|
+
|
|
|
+string content = match.Groups["content"].ToString();
|
|
|
+content.Display();
|
|
|
+
|
|
|
+#!csharp
|
|
|
+
|
|
|
+#!set --name test --value @csharp:smls
|
|
|
+using System.Text.RegularExpressions;
|
|
|
+
|
|
|
+string typePattern = @"(?<type>[(L)(A)(B)(Boolean)(I1)(I2)(I4)(I8)(U1)(U2)(U4)(U8)(F4)(F8)])";
|
|
|
+string contentPattern = @"(?<value>.*?)";
|
|
|
+string pattern = @$"<(?<content>{typePattern}\s+{contentPattern})>\.";
|
|
|
+
|
|
|
+test = Regex.Replace(test, @"(?=\S*?)\s{2,}", " ");
|
|
|
+test = Regex.Replace(test, @"\s+>", ">");
|
|
|
+test.Display();
|
|
|
+
|
|
|
+Match match = Regex.Match(test, pattern);
|
|
|
+// Match match = Regex.Match(test, pattern, RegexOptions.Singleline);
|
|
|
+while (match.Success) {
|
|
|
+ match.Groups["type"].ToString().Display();
|
|
|
+ match.Groups["value"].ToString().Display();
|
|
|
+ match.Groups["content"].ToString().Display();
|
|
|
+ "".Display();
|
|
|
+ match = match.NextMatch();
|
|
|
+}
|