mightguy mightguy - 1 year ago 251
C# Question

Error CS1525: Unexpected symbol `Match'

I'm trying to compile a code but the compiler give me this error

This is my code


using System;
using System.IO;
using System.Text.RegularExpressions;

class Program
static void Main()
string strpath = File.ReadAllText(@"C:\Users\mistery\Desktop\regex.txt");
Match match = Regex.Match(strpath, $"(?<=\\d{i} +(\\w)*.*?\\d) +(\\d+)"), RegexOptions.IgnoreCase);

Answer Source

You have an invalid ")" between the "pattern" and "options" parameters

String pattern = $"?<=\\d +(\\w)*.*?\\d) +(\\d+)"; // interpolation??
Match match = Regex.Match(strpath, pattern, RegexOptions.IgnoreCase);

$ is for the new string interpolation in C# 6

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download