Answer the question
In order to leave comments, you need to log in
Why doesn't the regular expression work?
Good afternoon!
I am writing a parser in C# that should accept and process json. The resulting json contains a lot of unicode escape characters like \\u0420\\u043e\\u0441.
As I understand it, the main thing is to replace 2 slashes with 1, and then it will turn out to get the desired text.
I'm trying to do it with regular expressions.
string test = "\u0022\\u0420\\u043e\\u0441\\u0441\\u0438\\u044f\u0022";
string check = Regex.Replace(test, @"\\", @"\");
Console.WriteLine(check);
Answer the question
In order to leave comments, you need to log in
Try like this:
Regex rx = new Regex( @"\\[uU]([0-9A-F]{4})" );
result = rx.Replace( result, match => ((char) Int32.Parse(match.Value.Substring(2), NumberStyles.HexNumber)).ToString() );
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question