05-01-2023, 11:11 PM
Thanks for your help!
I used chatgpt to change the previous code to C # 5, but still reported the same error,
Using linqpad5, the codes can be executed successfully
Error (RT) in Macro10: 0x80131600,
C#(13,74): error CS1061: 'System.Array' does not contain a definition for 'Skip' and no extension method 'Skip' accepting a first argument of type 'System.Array' could be found (are you missing a using directive or an assembly reference?)
C#(31,81): error CS1061: 'System.Array' does not contain a definition for 'Concat' and no extension method 'Concat' accepting a first argument of type 'System.Array' could be found (are you missing a using directive or an assembly reference?).
Macro Macro4
I used chatgpt to change the previous code to C # 5, but still reported the same error,
Using linqpad5, the codes can be executed successfully
Error (RT) in Macro10: 0x80131600,
C#(13,74): error CS1061: 'System.Array' does not contain a definition for 'Skip' and no extension method 'Skip' accepting a first argument of type 'System.Array' could be found (are you missing a using directive or an assembly reference?)
C#(31,81): error CS1061: 'System.Array' does not contain a definition for 'Concat' and no extension method 'Concat' accepting a first argument of type 'System.Array' could be found (are you missing a using directive or an assembly reference?).
Macro Macro4
_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: {0}", result[0]);
;;;;;;;;;Console.WriteLine("Group matches: {0}", 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[] { fullMatch } : new[] { 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)