Dinesh Kumar
asked on
regex (get all inputs of form)
How can I fetch the values of each input from the attached HTML using regular expression in c#.
please provide the code also and you need to explain it also in simple words. it will be much appreciated.
please provide the code also and you need to explain it also in simple words. it will be much appreciated.
ASKER
please provide the working code!
Hi,
May i know how is your input?
Because the regular expression you need to match the values and capture it.
Thanks
May i know how is your input?
Because the regular expression you need to match the values and capture it.
Thanks
ASKER
sorry it is attached now.
inputs.txt
inputs.txt
ASKER
suggestion:
I think if we can pick only all values i.e
value="2.0"
value="4314229999999913"
value="13"
and then looping it should do the work. is n't that guvera?
I think if we can pick only all values i.e
value="2.0"
value="4314229999999913"
value="13"
and then looping it should do the work. is n't that guvera?
yes you can try this below link from our expert exchange
https://www.experts-exchange.com/questions/23516269/Regular-expression-to-find-exact-matches.html?sfQueryTermInfo=1+10+30+c+each+express+fetch+input+regular+us+valu
https://www.experts-exchange.com/questions/23516269/Regular-expression-to-find-exact-matches.html?sfQueryTermInfo=1+10+30+c+each+express+fetch+input+regular+us+valu
before try this one add namespace
using System.Text.RegularExpress ions;
http://msdn.microsoft.com/en-us/library/30wbz966%28VS.71%29.aspx
using System.Text.RegularExpress
http://msdn.microsoft.com/en-us/library/30wbz966%28VS.71%29.aspx
ASKER
String regexPattern = "value='[^*']";
MatchCollection regexMatches = Regex.Matches(secondRespon seFromServ er, regexPattern, RegexOptions.IgnorePattern Whitespace | RegexOptions.Multiline | RegexOptions.Compiled | RegexOptions.IgnoreCase);
it matches only beginning single character of each value.
MatchCollection regexMatches = Regex.Matches(secondRespon
it matches only beginning single character of each value.
Hi Dinesh,
Certainly, using Regular Expression is one approach, however, that would involve a lot of hard work creating the regex. I would recommend that you use the HTML Agility Pack, which you can download from here:
http://htmlagilitypack.codeplex.com/
It does a lot of the heavy lifting that you need to do in order to parse the HTML.
Hope that helps!
Certainly, using Regular Expression is one approach, however, that would involve a lot of hard work creating the regex. I would recommend that you use the HTML Agility Pack, which you can download from here:
http://htmlagilitypack.codeplex.com/
It does a lot of the heavy lifting that you need to do in order to parse the HTML.
Hope that helps!
If u wish to match all your values, use
String regexPattern = "value='[a-zA-Z0-9.-:/]";
String regexPattern = "value='[a-zA-Z0-9.-:/]";
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This should give you just the value of each "value":
using System.Text.RegularExpressions;
Regex reg = new Regex("(?<=INPUT[^>]*?value=[\"']?)[^\"'>]*");
MatchCollection matches = reg.Matches(source_string);
foreach (Match m in matches)
{
//m.Value holds the matched text
}
ASKER
Kaufmed, please explain your regex!
ASKER
keen to accept multiple solutions.
kaufmed, please make these clear:
@"value='.*'"
why @ here?
good Shahan_Developer! can you make clear RegexOptions.IgnorePattern Whitespace | RegexOptions.Multiline ?
kaufmed, please make these clear:
@"value='.*'"
why @ here?
good Shahan_Developer! can you make clear RegexOptions.IgnorePattern
ASKER
kaufmed and Shahan_Developer, waiting for your post!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Please go through the below link for your question.
http://tim.oreilly.com/pub/a/oreilly/windows/news/csharp_0101.html
http://www.regular-expressions.info/dotnet.html
Hope that helps