Makar Emelyanov Makar Emelyanov - 3 days ago 7
C# Question

C# Regex Exception - insufficient hexadecimal digits

I am trying to write some regex pattern code that will take out certain parts of a text by using groups. Here is the code:

private static string ParseSnippet(string ownitDirectory, string project)
{
Match m = Regex.Match("(" + project + "\\\\.*\\\\)", ownitDirectory, RegexOptions.IgnoreCase);
return m.Groups[1].Value;
}


The problem I am having is that the pattern I am using causes an exception to occur. This exception does not make any sense to me. I have tested the pattern in plenty of online testers but this did not help the problem.

Would anybody have any suggestions as to what I should do?

EDIT:

Forgot to mention that the exception is "Insufficient hexadecimal digits"

Answer

According to this page, it seems that the parameters for Regex.Match are inverted. Have you tried this?

Regex.Match(ownitDirectory, "(" + project + "\\\\.*\\\\)", RegexOptions.IgnoreCase);
Comments