正则表达式
以一个变量开头开头,以</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" />
以一个变量开头开头,以</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" />
例如变量 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" />
我要获取这些集合
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();
}
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";
}
<textarea cols="40" class="bComment" name="p" id="p" rows="10"></textarea>
请在帮忙下,谢谢
这个字符里面的name的值和ID的值,用正则表达式怎么获取?