为了账号安全,请及时绑定邮箱和手机立即绑定

我要的是可以用的正则表达式 谢谢~

我要的是可以用的正则表达式 谢谢~

PHP C
慕勒3428872 2022-07-28 19:15:09
<td colspan="2">SV Kapfenberg - Rapid Wien <a href="javascript:openResizeAbleWindow('redirStats.aspx?url=aHR0cDovL3d3dy5zdGF0cy5iZXRyYWRhci5jb20vc3RhdGlzdGljcy9saXZlc2NvcmVjYy8/bWF0Y2hpZD03NzU1OTUmdHJlZW1lbnU9ZmFsc2UmbGFuZ3VhZ2U9ZGU=&cid=1906', 'statistics', 756, 650, true)"> <img class='MatchStatImg' src='pic/table/symbol_spielstatistik.gif' /> </a> </td><td colspan="2">SV Kapfenberg - Rapid Wien </td>现在就要匹配 <td> </td>之间的内容得到结果SV Kapfenberg - Rapid WienSV Kapfenberg - Rapid Wien再来第二个 不好意思了 呵呵<td class="OT_Col_Odd_BR"onMouseOut="javascript:this.className='OT_Col_Odd_BR'" onMouseOver="javascript:this.className='OT_Col_Odd_BR_Over'"id='814986_1'onclick="javascript:f_addToBetslip(this,814986,'5.00', 'SV Kapfenberg - Rapid Wien ', 1, 296067, 'True', 3, 'Tipp', '1')">5,00</td><td class="OT_Col_Odd_BR"onMouseOut="javascript:this.className='OT_Col_Odd_BR'" onMouseOver="javascript:this.className='OT_Col_Odd_BR_Over'"id='817169_1'onclick="javascript:f_addToBetslip(this,817169,'2.70', 'DSV Leoben - FK Austria Magna (A) ', 1, 296691, 'True', 3, 'Tipp', '1')">2,70</td>得出结果5,002,70页面上有很多td 并且td中的有些数据是不想要的用内文本的方法是拿不出来的了我这要用的是PHP
查看完整描述

3 回答

?
茅侃侃

TA贡献1842条经验 获得超21个赞

正则表达式如下:

问题1:
正则表达式: \<td colspan=\"2\"\>.*?\<a href.*?
被测试字符串:
<td colspan="2">SV Kapfenberg - Rapid Wien <a href="javascript:openResizeAbleWindow('redirStats.aspx?
测试结果为:
array[0] = '<td colspan="2">SV Kapfenberg - Rapid Wien <a href'
array[1] = '<td colspan="2">'
array[2] = 'SV Kapfenberg - Rapid Wien '
array[3] = '<a href'

问题2:
正则表达式: .*?javascript:f_addToBetslip\(this,817169,\'(.*?)\',.*?
被测试字符串:
onclick="javascript:f_addToBetslip(this,817169,'2.70', 'DSV Leoben - FK Austria Magna (A) ', 1, 296691, 'True', 3, 'Tipp', '1')">

测试结果:

array[0] = 'onclick="javascript:f_addToBetslip(this,817169,'2.70','
array[1] = '2.70'


查看完整回答
反对 回复 2022-08-01
?
素胚勾勒不出你

TA贡献1827条经验 获得超9个赞

td.innerText 就是你要的内容,不需要用正则

测试代码:
<html>
<head>
<script>
function wahaha()
{
for(var i=0; i<x.cells.length; i++)
{
alert(x.cells[i].innerText);
}
for(var i=0; i<y.cells.length; i++)
{
alert(y.cells[i].innerText);
}
}
</script>
</head>
<body onload="wahaha()">
<table>
<tr id="x">
<td colspan="2">SV Kapfenberg - Rapid Wien <a href="javascript:openResizeAbleWindow('redirStats.aspx?url=aHR0cDovL3d3dy5zdGF0cy5iZXRyYWRhci5jb20vc3RhdGlzdGljcy9saXZlc2NvcmVjYy8/bWF0Y2hpZD03NzU1OTUmdHJlZW1lbnU9ZmFsc2UmbGFuZ3VhZ2U9ZGU=&cid=1906', 'statistics', 756, 650, true)"> <img class='MatchStatImg' src='pic/table/symbol_spielstatistik.gif' /> </a> </td>

<td colspan="2">SV Kapfenberg - Rapid Wien </td>
</tr>
<tr id="y">
<td class="OT_Col_Odd_BR"
onMouseOut="javascript:this.className='OT_Col_Odd_BR'" onMouseOver="javascript:this.className='OT_Col_Odd_BR_Over'"
id='814986_1'
onclick="javascript:f_addToBetslip(this,814986,'5.00', 'SV Kapfenberg - Rapid Wien ', 1, 296067, 'True', 3, 'Tipp', '1')">
5,00
</td>

<td class="OT_Col_Odd_BR"
onMouseOut="javascript:this.className='OT_Col_Odd_BR'" onMouseOver="javascript:this.className='OT_Col_Odd_BR_Over'"
id='817169_1'
onclick="javascript:f_addToBetslip(this,817169,'2.70', 'DSV Leoben - FK Austria Magna (A) ', 1, 296691, 'True', 3, 'Tipp', '1')">
2,70
</td>
</tr>
</table>
</body>
</html>


查看完整回答
反对 回复 2022-08-01
?
LEATH

TA贡献1936条经验 获得超6个赞

下面的代码是你要的:

<script type="text/javascript" language="javascript">
function GetAnswer() {
var o = document.getElementById("txt")
alert(o.value.replace(/<\/?.+?>/g,""));
}
</script>
<input type="text" id="txt" style="width: 292px; height: 226px" value="" />
<input type="button" value="GetAnswer" onclick="return GetAnswer();" />

======================================

补充

======================================

php里你自己的测一下了

<?php
$a="准备过滤的源字符串";
$i = preg_replace("/<\/?.+?>/","",$a);
echo $i;
?>


查看完整回答
反对 回复 2022-08-01
  • 3 回答
  • 0 关注
  • 187 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信