正则表达式获取字符串中html<input>标签指定value值

        /// <summary>
        /// 通过正则表达式获取字符串中html<input>标签指定value值
        /// </summary>
        /// <param name="FileString">包含html的字符串</param>
        /// <param name="inputName">指定<input>控件的名称</param>
        /// <returns></returns>
        public string GetInput(string FileString, string inputName)
        {
            string inputValue = "";
            MatchCollection matches = Regex.Matches(FileString, @"(?is)<input[^>]+type=""(?:hidden)""[^>]+name=""(?:"+inputName+@")""[^>]+value=""(.+?)""[^>]*>");
            foreach (Match match in matches)
                inputValue += match.Groups[1].Value;

            return inputValue;
        }
原文地址:https://www.cnblogs.com/captainR/p/2805203.html