I have encountered many similar problems, for example, the C # code below will prompt an error during execution
#1. What is the highest supported version of C#? C#5?
#2. Is there a better way to make the code in QM support C#6? or High? (.NET Framework 4.6 suport C#6.0)
Thanks for any suggestions and help
david
Macro Macro9
#1. What is the highest supported version of C#? C#5?
#2. Is there a better way to make the code in QM support C#6? or High? (.NET Framework 4.6 suport C#6.0)
Thanks for any suggestions and help
david
Macro Macro9
_s=
;using System;
;using System.Linq;
;using System.Text.RegularExpressions;
;
;public class Program
;{
;,public static void Main()
;,{
;,,string s = "xzc abc(s \"(abc)\")); dfg()";
;,,string p = @"abc\(((?:(?>[^()]*)|\((?<Open>)|\)(?<-Open>))*(?(Open)(?!)))\)";
;,,string[] result = FindMatch(s, p);
;,,Console.WriteLine("Full match: " + result[0]);
;,,Console.WriteLine("Group matches: " + string.Join(", ", result.Skip(1)));
;,}
;
;,public static string[] FindMatch(string s, string pattern)
;,{
;,,Match match = Regex.Match(s, pattern);
;,,string fullMatch = match.Value;
;
;,,string[] groupMatches = null;
;,,if (match.Groups.Count > 1)
;,,{
;,,,groupMatches = new string[match.Groups.Count - 1];
;,,,for (int i = 1; i < match.Groups.Count; i++)
;,,,{
;,,,,groupMatches[i - 1] = match.Groups[i].Value;
;,,,}
;,,}
;
;,,return groupMatches == null ? new string[] { fullMatch } : new string[] { fullMatch }.Concat(groupMatches).ToArray();
;,}
;}
str s=
;xzc abc(s \"(abc)\")); dfg()
str s2=
;abc\(((?:(?>[^()]*)|\((?<Open>)|\)(?<-Open>))*(?(Open)(?!)))\)
CsScript x.AddCode(_s)
out x.Call("Program.FindMatch" s s2)