找回密码
 加入
搜索
查看: 4815|回复: 9

[IE类操作] 求一个简单正则·

  [复制链接]
发表于 2013-11-6 11:21:45 | 显示全部楼层 |阅读模式
本帖最后由 5735988 于 2013-11-6 12:48 编辑

<table width="650" height=29"30"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr class="unnamed1">
    <td width="157"><div align="center"><a href="#" onClick="javascript:window.open('list.asp?id=2939','InfoDetail','toolbar=no,scrollbars=yes,resizable=yes,top=0,left=0,width=440 height=510'); "><font color="#FFFFFF">234434</a></div></td>
         <td width="157"><div align="center"><a href="#" onClick="javascript:window.open('list.asp?id=2939','InfoDetail','toolbar=no,scrollbars=yes,resizable=yes,top=0,left=0,width=440 height=510'); "><font color="#FFFFFF">任</a></div></td>
        <td width="140"><div align="center"><a href="#" onClick="javascript:window.open('list.asp?id=2939','InfoDetail','toolbar=no,scrollbars=yes,resizable=yes,top=0,left=0,width=440 height=510'); "><font color="#FFFFFF">15027131813</a></div></td>
    <td width="135"><div align="center"><font color="#FFFFFF">2013-11-6 12:17:58</div></td>
    <td width="78">
    <p align="center"><a href="deluser.asp?id=2939"><font color="#FF0000">
      删除</font></a></td>
    <td width="88"><div align="center"><font color="#FF0000">&nbsp;</font><span style="font-size: 9pt"><input name="selAnnounce" type="checkbox" value="2939" /></span></div></td>
</div></td>
  </tr>
</table>
<table width="453"  border="0" align="center" cellpadding="0" cellspacing="0" background="images/bg1.gif">
  <tr>
    <td width="453"><img src="images/bg1.gif" width="3" height="1"></td>
  </tr>
</table>



$Str = FileRead("1.txt")
$sR = StringRegExp($Str, '(?i)id=(\d+)', 3)
Msgbox(0, $Str, $sR[0])



我要提取ID = 后面的数字   上面这个  deluser.asp?id=2939
     2939 就出现一次就可以了。刚刚我没有发完整代码。

谢谢
发表于 2013-11-6 11:54:40 | 显示全部楼层
(?i)id=(\d+)

评分

参与人数 1金钱 +30 贡献 +2 收起 理由
tryhi + 30 + 2

查看全部评分

 楼主| 发表于 2013-11-6 12:51:16 | 显示全部楼层
回复 2# haijie1223


    麻烦在帮我看下,我刚刚没有发完整代码,导致读取出来的,2939 重复了4次。

只需要提取一次就可以了。,谢谢
 楼主| 发表于 2013-11-6 12:56:08 | 显示全部楼层
<p align="center"><a href="deluser.asp?id=2939"><font color="#FF0000">
发表于 2013-11-6 13:06:20 | 显示全部楼层
回复 3# 5735988


    不知道你到底想干什么啊,难道是是获取用户的id?
(?i)deluser\.asp\?id=(\d+)
发表于 2013-11-6 14:03:52 | 显示全部楼层
好复杂的东西,想学
发表于 2013-11-6 14:30:52 | 显示全部楼层
(?<=deluser.asp\?id=)\d+
发表于 2013-11-13 11:36:13 | 显示全部楼层
其实用字符串提取也可以。返回文件的字符位置。然后慢慢割取就好了。只不过正则更快。更方便
发表于 2013-11-13 22:06:01 | 显示全部楼层
$Str = FileRead("1.txt")
$sR = StringRegExp($Str, 'deluser.asp\?id=(.+?)"', 3)
Msgbox(0, $Str, $sR[0])
发表于 2013-11-13 22:07:04 | 显示全部楼层
错了,应该是

$Str = FileRead("1.txt")
$sR = StringRegExp($Str, 'deluser\.asp\?id=(.+?)"', 3)
Msgbox(0, $Str, $sR[0])
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-3 23:41 , Processed in 0.089557 second(s), 27 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表