We Recommend

Accelerated C# 2008 Accelerated C# 2008
This book is both a rapid tutorial and a permanent reference. You’ll quickly master C# syntax while learning how the CLR simplifies many programming tasks. You’ll also learn best practices that ensure your code will be efficient, reusable, and robust. Why spend months or years discovering the best ways to design and code C# when this book will show you how to do things the right way, right from the start?


Posted By

zvasanth on 12/29/07


Tagged

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


Versions (?)


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.