是在javascript 中实现吗,如果这样的话直接用string text=document.getElementById("sn_dt_masing").innerHTML就可以取出<div >xxx </div>之间的字符串内容,然后用字符串函数处理
解决方案 »
- 请教问题。。。
- 如何让 table中的背景图片填充满
- 求救:ajax 获取值问题
- 给控件添加事件(急40分)
- DataKey key = GridView1.DataKeys[index]; 索引超出范围。必须为非负
- 静态页面的问题
- 显示比较DataGrid的列值Cell的问题
- Infragistics.WebUI.UltraWebGrid里的DatabaseUpdating 里的 UltraWebGrid1_DeleteRow 是在面面的那里按了删除呀?
- 关于用框架和不用框架的疑问,望高手们告知
- 如何新增XML新节点?
- 怎么让服务器控件不发送回服务器执行
- 帮我翻译一个句子,“基于ASP.NET考研BBS系统”我论文的题目
$("div")过滤
string str="<div id=\"sn_dt_masing\">24 years old, Male </div>...";
System.Text.RegularExpressions.Regex reg=new System.Text.RegularExpressions.Regex(@"<div.*?>(?<text>[^><].*?)</div>",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.MatchCollection m = reg.Matches(str); //设定要查找的字符串
for (int i = 0; i < m.Count; i++)
{
Response.Write(m[i].Groups["text"].ToString());
}
"(?<=>).+?(?=<)"用正则匹配的集合matchs方法全部取出.
foreach (Match m in mc)
{
richTextBox2.Text += m.Value + "\n";
}
新建一个文件,把数据拷贝到这个文件。<div id="sn_dt_masing">24 years old, Male </div>
<div id="sn_dt_abttxt">喜好音乐,酷爱运动。 人生没有过去的坎! </div>
<div class="sn_dt_itmhdr">Location </div>
<div class="sn_dt_itmdtl" id="sn_dt_gn_loc">杭州 </div>
<div class="sn_dt_itmhdr">Occupation </div>
<div class="sn_dt_itmdtl" id="sn_dt_gn_oc">IT </div>
点排序按钮,选择“比较由正则表达式定义的字符串”,输入下面的正则表达式和目标字符串(没有空格):
正则表达式:<div*>*</div>
目标字符串:%04点“将目标字符串拷贝到剪贴板”,即可将你要的数据拷贝到剪贴板:24 years old, Male
喜好音乐,酷爱运动。 人生没有过去的坎!
Location
杭州
Occupation
IT
string html ="<div>xxx</div>";
html = Regex.Replace(html, "<[^>]+>", "");