js中按找规则截取字符串 本帖最后由 saybookcat 于 2014-05-23 12:41:39 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你的描述与结果不一致<td class="content" id="c_F111029_0" style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 16px;" dbid="DB111">n<table>n<tbody>n<tr>n<td class="content" id="cpp_content_i0" style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 16px;">常用正则表达式大全匹配日期时间 没明白规则,这项不符合你说的么<td>标签里class="content"的项<td class="content" id="c_F111015_0" style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 16px;" dbid="DB111">赞助商广告 </td> 感谢楼上两位提出,帖子好像不能修改了 截取结果应该是<td class="content" id="cpp_content_i0" style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 16px;">常用正则表达式大全匹配日期时间" 版主 这样 不合适吧 <td class="content" 是不是分开作为2个字符比较好呢 <script type="text/javascript"> var str = '<td title="GK_PA" class="title" id="t_F111015_0" style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 16px;" dbid="DB111">申请人 - </td>n<td class="content" id="c_F111015_0" style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 16px;" dbid="DB111">赞助商广告 </td></tr>n<tr id="F111152">n<td title="GK_IN" class="title" id="t_F111152_0" style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 16px;" dbid="DB111">名称 - </td>n<td class="content" id="c_F111152_0" style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 16px;" dbid="DB111">附录【所有元字符】附录【所有元字符】</td></tr>n<tr id="F111195">n<td title="GK_IC" class="title" id="t_F111195_0" style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 16px;" dbid="DB111">IPC - </td>n<td class="content" id="c_F111195_0" style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 16px;" dbid="DB111">H04Q7/34</td></tr>n<tr id="F111052">n<td title="GK_TI" class="title" id="t_F111052_0" style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 16px;" dbid="DB111">名称 - </td>n<td class="content" id="c_F111052_0" style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 16px;" dbid="DB111">处理选项</td></tr>n<tr id="F111207">n<td title="GK_ICST" class="title" id="t_F111207_0" style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 16px;" dbid="DB111">ICST - </td>n<td class="content" id="c_F111207_0" style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 16px;" dbid="DB111">H04Q7/34</td></tr>n<tr id="F111029">n<td title="GK_AB" class="title" id="t_F111029_0" style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 16px;" dbid="DB111">摘要 - </td>n<td class="content" id="c_F111029_0" style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 16px;" dbid="DB111">n<table>n<tbody>n<tr>n<td class="content" id="cpp_content_i0" style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 16px;">常用正则表达式大全匹配日期时间"<td>'; var result = str.substr(str.lastIndexOf('<td class="content"')); alert(result.substring(0, result.indexOf('<', result.indexOf('<')+1))); </script> 怎样判断html element 是否是隐藏的 请问jiathis的代码与jquery有冲突,应该怎么解决?急!!! 请教javascript的tree算法 js中上下滚动字幕 有没有支持FireFox的从右到左连无缝续滚动图片的脚本? 请问高手:这样的防盗链功能怎样实现? 表单验证double 型数据问题 window.open()总是弹出一个新的窗口,如何对弹出的新窗口进行判断,如果它存在就刷新,如果不存在才弹出? ☆☆☆☆☆哈,,刚想到的。。以后不用为ID的分配发傻了。。 请问用办法,可以禁止用户按F5刷新吗?如果怎么写 上传图片 xzy21com真心谢谢您的帮助 还有一个类似的问题
<td class="content" id="c_F111029_0" style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 16px;" dbid="DB111">n<table>n<tbody>n<tr>n<td class="content" id="cpp_content_i0" style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 16px;">常用正则表达式大全匹配日期时间
没明白规则,这项不符合你说的么
<td>标签里class="content"的项
<td class="content" id="c_F111015_0" style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 16px;" dbid="DB111">赞助商广告 </td>
截取结果应该是
<td class="content" id="cpp_content_i0" style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 16px;">常用正则表达式大全匹配日期时间"
<script type="text/javascript"> var str = '<td title="GK_PA" class="title" id="t_F111015_0" style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 16px;" dbid="DB111">申请人 - </td>n<td class="content" id="c_F111015_0" style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 16px;" dbid="DB111">赞助商广告 </td></tr>n<tr id="F111152">n<td title="GK_IN" class="title" id="t_F111152_0" style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 16px;" dbid="DB111">名称 - </td>n<td class="content" id="c_F111152_0" style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 16px;" dbid="DB111">附录【所有元字符】附录【所有元字符】</td></tr>n<tr id="F111195">n<td title="GK_IC" class="title" id="t_F111195_0" style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 16px;" dbid="DB111">IPC - </td>n<td class="content" id="c_F111195_0" style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 16px;" dbid="DB111">H04Q7/34</td></tr>n<tr id="F111052">n<td title="GK_TI" class="title" id="t_F111052_0" style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 16px;" dbid="DB111">名称 - </td>n<td class="content" id="c_F111052_0" style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 16px;" dbid="DB111">处理选项</td></tr>n<tr id="F111207">n<td title="GK_ICST" class="title" id="t_F111207_0" style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 16px;" dbid="DB111">ICST - </td>n<td class="content" id="c_F111207_0" style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 16px;" dbid="DB111">H04Q7/34</td></tr>n<tr id="F111029">n<td title="GK_AB" class="title" id="t_F111029_0" style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 16px;" dbid="DB111">摘要 - </td>n<td class="content" id="c_F111029_0" style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 16px;" dbid="DB111">n<table>n<tbody>n<tr>n<td class="content" id="cpp_content_i0" style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 16px;">常用正则表达式大全匹配日期时间"<td>'; var result = str.substr(str.lastIndexOf('<td class="content"'));
alert(result.substring(0, result.indexOf('<', result.indexOf('<')+1)));
</script>