正则表达式从表单帖子中检索值(我说R字,对不起) [英] Regex retrieve value from form post (I said the R word, sorry)

查看:73
本文介绍了正则表达式从表单帖子中检索值(我说R字,对不起)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些正在读取并填充到数据库中的数据。我还有更多的东西要从Regex中读取,就像往常一样,当它的最后一件事情和一切都很顺利的时候,哈 - 不!! 这是在我的计算机上的页面上进行硬编码,而不是http。 我用
使用visual studio 2017

I have some data that is being read and populated into a DB. I have just on more thing to read from Regex, like always, when its the last thing and everything is going good, ha-Nope!.  This is hard coded on pages on my computer, not http.  I'm using visual studio 2017

这是表单部分:

< input name =" amount"类型= QUOT;隐藏"&NBSP;值= QUOT; 1.99" />&NBSP;所以,我希望在没有引号的情况下提取1.99。

<input name="amount" type="hidden" value="1.99" />  so, I'm looking to extract 1.99 with no quotes.

我尝试了多种变体: 

I have tried multiple variations: 

(@"< input * *量类型= .hidden *值= * [(\d {1,3})(\,\d {3})* |。。(\d +)(\.\ 。d {2})]");但包含标签

(@"<input.*amount.*type=.hidden.*value=.*[(\d{1,3})(\,\d{3})*|(\d+)(\.\d{2})]."); works but tag included

(@"< input \s.amount.\stype = .hidden.\svalue =。[(\d {1,3} )(\,\d {3})* |(\d +)(\.\d {2})] QUOT。);没有结果返回。  

(@"<input\s.amount.\stype=.hidden.\svalue=.[(\d{1,3})(\,\d{3})*|(\d+)(\.\d{2})]."); no results returned.  

我知道我很接近,但努力工作让你变成一个沉闷的男孩。 

I know I'm close, but working to hard makes you a dull boy. 

谢谢提前

推荐答案

如果您只需要十进制数字,可以尝试:
If you only need the decimal number, you could try:
string line = "<input name=\"amount\" type=\"hidden\" value=\"1.99\" />";
string pattern = @"\d+\.\d+";
string value = Regex.Match(line, pattern).Value;


wizend

wizend


这篇关于正则表达式从表单帖子中检索值(我说R字,对不起)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆