62,074
社区成员
发帖
与我相关
我的任务
分享
string test = @"<td><input title=会议>
</td>
<td>
<select title=密级><option value=一 selected></option><option value=一></option>
</select>
</td>
<td>
<textarea title内容><textarea>
</td>
<td>
</td>
";
Regex reg = new Regex(@"(?i)(?<=<(?:select|input|textarea))(?=[^>]*>)");
int i = 0;
string result = reg.Replace(test, delegate(Match m) { return " id=\"data" + ++i + "\" name=\"data" + i + "\""; });
richTextBox2.Text = result;