在线100分等两个正则表达式写法,急
正则表达式以一个变量开头开头,以</from>结尾
例如变量 string action="action="http://dafsd.com/post.aspx";
我想获取action开头到</from>结束直接的字符
第二个我想获取页面<input class="bComment" size="40" type="text" name="u" id="u" />
包括type="text"的所有数据集合,获取出来结果为<input class="bComment" size="40" type="text" name="u" id="u" />
--------------------编程问答-------------------- 1.楼主需要js正则,还是C#后台正则.
2.另外建议楼主从新陈述下问题。 --------------------编程问答-------------------- 第二个不需要正则就可实际.遍历页面里的控件,找到type为text的就可以了。。第一个看着不明白。。 --------------------编程问答-------------------- 我需要的是C#正则表达式
例如变量 string action="action="http://dafsd.com/post.aspx";
我想获取action开头到</from>结束之间的字符
第二个我想获取所有包含type="text"字符的控件
例如我要获取的结果是
<input class="bComment" size="40" type="text" name="u" id="u" />
<input size="40" type="text" id="b" />
<input size="40" type="text" id="c" />
我要获取这些集合 --------------------编程问答-------------------- 我要通过c# 正则表达式解析HTML字符串 --------------------编程问答--------------------
--------------------编程问答-------------------- 第一个:@"action[\s\S]+?</form>"
Match m = Regex.Matches(原字符串,
@"(?<=action=\")[^<]+",RegexOptions.IgnoreCase);
if (m.Success) string action=m;
string input;
MatchCollection matches = Regex.Matches(原字符串,
@"<.{0,2}input[^>]+type.{0,3}text[^>]+>",RegexOptions.IgnoreCase);
foreach(Match match in matches)
{
xxx+==match.ToString();
}
第二个:"<.+?type=\"text\".+?>"
我用的是RCRE的正则, 不知道可以否, 你可以试试 --------------------编程问答-------------------- 小毛病更正一下
--------------------编程问答-------------------- 1、
string action="";
Match m = Regex.Match(原字符串, "(?<=action=\")[^>\"]+",RegexOptions.IgnoreCase);
if (m.Success) action=m.ToString();
string inputs="";
MatchCollection matches = Regex.Matches(原字符串,"<.{0,2}input[^>]+type.{0,3}text[^>]+>",RegexOptions.IgnoreCase);
foreach(Match match in matches)
{
inputs+=match.ToString();
}
string action = Regex.Escape("action=\"http://dafsd.com/post.aspx");
Regex reg = new Regex(@"(?is)" + action + "(.*?)</from>");
MatchCollection mc = reg.Matches(yourStr);
foreach (Match m in mc)
{
richTextBox2.Text += m.Groups[1].Value + "\n";
}
2、
Regex reg = new Regex(@"<input[^>]*?type=""text""[^>]*>");--------------------编程问答-------------------- 谢谢你们,还有一个
MatchCollection mc = reg.Matches(yourStr);
foreach (Match m in mc)
{
richTextBox2.Text += m.Value + "\n";
}
我要找这样格式的集合类型刚才type="text" 哪个方式
<textarea cols="40" class="bComment" name="p" id="p" rows="10"></textarea>
请在帮忙下,谢谢 --------------------编程问答-------------------- 还有,我想获取<textarea cols="40" class="bComment" name="p" id="p" rows="10"></textarea>
这个字符里面的name的值和ID的值,用正则表达式怎么获取? --------------------编程问答-------------------- 大家帮帮忙啊
补充:.NET技术 , ASP.NET