Basically, I am trying to remove special character from xml file. I have tried the below code. I have tested with regex tester. It's working fine. In the production machine, it is replacing string.Empty for = character which is valid.
using System;
using System.Text.RegularExpressions;
class Program
{
static void Main(string[] args)
{
string xmlString = "<root><name>John & = Doe</name></root>";
// Replace special characters with their XML entities
string cleanedXml = Regex.Replace(xmlString, @"[^\u09\u0A\u0D\u20-\uD7FF\uE000-\uFFFD\u10000-\u10FFFF]",
string.Empty);
Console.WriteLine(cleanedXml);
}
}
Culture : en-US in the prod machine.
Please anyone help me on this why it's happening. What's problem in the regex expression? Why regex is replacing equal symbol on prod machine alone? I am using. Net framework 4.8 version.