C# 正则表达式替换JSON格式字符串中某段字符串


DEMO:

            //正则表达式替换JSON格式字符串中某段字符串
            string replacement = @"""DoorIds"":"""",""IsChecked"":false,";
            var regex = new System.Text.RegularExpressions.Regex(@"""DoorIds"":""\[.{0,100}\]"",""IsChecked"":[a-zA-Z]{0,5},");
            bool isMatch = regex.IsMatch(inputString);
            if (isMatch)
            {
                inputString = regex.Replace(inputString, replacement);
            }