正则表达式 匹配以特定字符串开头 到任意第一个字符中间的空格

(?<=<p style="text-indent:2em;">)[^\S]+    //正则表达式 匹配以特定字符串开头 到任意第一个字符中间的空格


(?<=<p style="text-indent:2em;">)[^\u4e00-\u9fa5]+        //正则表达式 匹配以特定字符串开头 到任意第一个字符中间的空格

 Regex rgx = new Regex("(?<=<p style=\"text-indent:2em;\">)[^\\S]+");
            Match mat = rgx.Match(model.Detail);
            string modelStr = model.Detail;
            //modelStr = rgx.Replace(model.Detail, "");
            if (mat.Success)
            {
                MatchCollection mc = rgx.Matches(modelStr);
                for (int i = 0; i < mc.Count; i++)
                {
                    int index = mc[i].Index;
                    int length = mc[i].Length;
                    modelStr =modelStr.Replace(modelStr.Substring(index, length),"");
                    mc = rgx.Matches(modelStr);
                }
            }
            model.Detail = modelStr;


猜你喜欢

转载自blog.csdn.net/fy809178958/article/details/78559264