Posted By

zvasanth on 12/29/07


Tagged

regex get html page input multiline name Value regular Expression controls in and regexoptions


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

umang_nine
vali29
emregulcan


Get Input Controls Name And Value In HTML Page


 / Published in: C#
 

URL: ideabubbling.com

Everything is either true or untrue, or both true and untrue, or neither true nor untrue - nagarguna

  1. public static string GetInputControlsNameAndValueInPage(string strPage)
  2. {
  3. string strRegExPatten = "<\\s*input.*?name\\s*=\\s*\"(?<Name>.*?)\".*?value\\s*=\\s*\"(?<Value>.*?)\".*?>";
  4. Regex reg = new Regex(strRegExPatten, RegexOptions.Multiline);
  5. MatchCollection mc = reg.Matches(strPage);
  6. string strTemp = string.Empty;
  7. foreach (Match m in mc)
  8. {
  9. strTemp = strTemp + m.Groups["Name"].Value + "=" + m.Groups["Value"].Value + "&";
  10. }
  11. int n = strTemp.Length;
  12. strTemp = strTemp.Remove(n - 1);
  13. return strTemp;
  14. }

Report this snippet  

You need to login to post a comment.