找回密码
 加入
搜索
查看: 5340|回复: 8

[AU3基础] 请教该正则应如何写

  [复制链接]
发表于 2012-6-16 22:08:48 | 显示全部楼层 |阅读模式
<tr><td width="140">IP:Port</td><td width="40">Type</td><td width="90">Speed</td><td width="160"> Country/Area</td></tr>
<tr><td>119.82.252.7<SCRIPT type=text/javascript>document.write(":"+r+d+r+d)</SCRIPT></td><td>HTTP</td><td>219,938,938</td><td>柬埔寨</td></tr>
<tr><td>202.43.179.182<SCRIPT type=text/javascript>document.write(":"+b+m+z+k+c)</SCRIPT></td><td>HTTP</td><td>187,953,953</td><td>印度尼西亚 MORA电信</td></tr>
<tr><td>202.171.253.98<SCRIPT type=text/javascript>document.write(":"+r+d)</SCRIPT></td><td>HTTP</td><td>78,375,375</td><td>澳门 Macauweb公司</td></tr>
<tr><td>203.66.187.246<SCRIPT type=text/javascript>document.write(":"+r+d)</SCRIPT></td><td>HTTP</td><td>125,844,844</td><td>台湾省 中华电信</td></tr>
<tr><td>203.66.187.246<SCRIPT type=text/javascript>document.write(":"+r+c)</SCRIPT></td><td>HTTP</td><td>109,969,984</td><td>台湾省 中华电信</td></tr>
<tr><td>207.211.86.196<SCRIPT type=text/javascript>document.write(":"+r+d)</SCRIPT></td><td>HTTP</td><td>219,875,875</td><td>United States</td></tr>
<tr><td>41.35.48.30<SCRIPT type=text/javascript>document.write(":"+r+d+r+d)</SCRIPT></td><td>HTTP</td><td>500,1359,1390</td><td>Egypt</td></tr>
<tr><td>41.43.31.134<SCRIPT type=text/javascript>document.write(":"+r+d+r+d)</SCRIPT></td><td>HTTP</td><td>641,1922,1953</td><td>Egypt</td></tr>
<tr><td>41.215.247.146<SCRIPT type=text/javascript>document.write(":"+r+d+r+d)</SCRIPT></td><td>HTTP</td><td>594,1813,1813</td><td>尼日利亚</td></tr>
<tr><td>68.71.76.242<SCRIPT type=text/javascript>document.write(":"+r+d+r+k)</SCRIPT></td><td>HTTP</td><td>266,1234,1250</td><td>United States</td></tr>
<tr><td>80.75.15.157<SCRIPT type=text/javascript>document.write(":"+r+d+r+d)</SCRIPT></td><td>HTTP</td><td>516,1735,1750</td><td>Iran</td></tr>
<tr><td>112.217.228.212<SCRIPT type=text/javascript>document.write(":"+r+d+r+d)</SCRIPT></td><td>HTTP</td><td>156,1000,1140</td><td>Korea</td></tr>
<tr><td>115.124.69.58<SCRIPT type=text/javascript>document.write(":"+r+d)</SCRIPT></td><td>HTTP</td><td>375,1453,1468</td><td>印度尼西亚 雅加达市</td></tr>
<tr><td>116.90.211.136<SCRIPT type=text/javascript>document.write(":"+r+d+r+d)</SCRIPT></td><td>HTTP</td><td>313,1313,1328</td><td>Indonesia</td></tr>
<tr><td>118.96.153.254<SCRIPT type=text/javascript>document.write(":"+r+d+r+d)</SCRIPT></td><td>HTTP</td><td>453,1656,1687</td><td>Indonesia</td></tr>
<tr><td>118.97.71.57<SCRIPT type=text/javascript>document.write(":"+r+d+r+d)</SCRIPT></td><td>HTTP</td><td>219,1016,1016</td><td>Indonesia</td></tr>
<tr><td>118.97.170.195<SCRIPT type=text/javascript>document.write(":"+r+d+r+d)</SCRIPT></td><td>HTTP</td><td>343,1203,1750</td><td>Indonesia</td></tr>
<tr><td>118.97.221.53<SCRIPT type=text/javascript>document.write(":"+r+d+r+d)</SCRIPT></td><td>HTTP</td><td>375,1406,1797</td><td>Indonesia</td></tr>
<tr><td>122.200.54.42<SCRIPT type=text/javascript>document.write(":"+r+d)</SCRIPT></td><td>HTTP</td><td>485,1719,1719</td><td>Indonesia</td></tr>



document.write(":"+r+d+r+d)则用下面代码表解码 +r+d+r+d = 8080
z="3";m="4";k="2";l="9";d="0";b="5";i="7";w="6";r="8";c="1";

正则转换下面的格式。。
119.82.252.7:8080        HTTP        219,938,938        柬埔寨
202.43.179.182:54321        HTTP        187,953,953        印度尼西亚 MORA电信
202.171.253.98:80        HTTP        78,375,375        澳门 Macauweb公司
203.66.187.246:80        HTTP        125,844,844        台湾省 中华电信
203.66.187.246:81        HTTP        109,969,984        台湾省 中华电信
207.211.86.196:80        HTTP        219,875,875        United States
41.35.48.30:8080        HTTP        500,1359,1390        Egypt
41.43.31.134:8080        HTTP        641,1922,1953        Egypt
41.215.247.146:8080        HTTP        594,1813,1813        尼日利亚
68.71.76.242:8082        HTTP        266,1234,1250        United States
发表于 2012-6-16 22:14:06 | 显示全部楼层
正则匹配的字符是不能直接使用(运算、转换等)的,只能提取出来,转换后再替换原处。
 楼主| 发表于 2012-6-16 22:20:57 | 显示全部楼层
回复 2# afan


    哦。。以为正则有提取和正则替换。。两个可以整合到一起写

那正则替换多个如何写如 +d 替换成8 +r 替换成0 还是其它也要替换
如何用stringreplace..要好几次才能完成
发表于 2012-6-16 22:54:08 | 显示全部楼层
Local $Str = _
                '<tr><td width="140">IP:Port</td><td width="40">Type</td><td width="90">Speed</td><td width="160"> Country/Area</td></tr>' & @CRLF & _
                '<tr><td>119.82.252.7<SCRIPT type=text/javascript>document.write(":"+r+d+r+d)</SCRIPT></td><td>HTTP</td><td>219,938,938</td><td>柬埔寨</td></tr>' & @CRLF & _
                '<tr><td>202.43.179.182<SCRIPT type=text/javascript>document.write(":"+b+m+z+k+c)</SCRIPT></td><td>HTTP</td><td>187,953,953</td><td>印度尼西亚 MORA电信</td></tr>' & @CRLF & _
                '<tr><td>202.171.253.98<SCRIPT type=text/javascript>document.write(":"+r+d)</SCRIPT></td><td>HTTP</td><td>78,375,375</td><td>澳门 Macauweb公司</td></tr>' & @CRLF & _
                '<tr><td>203.66.187.246<SCRIPT type=text/javascript>document.write(":"+r+d)</SCRIPT></td><td>HTTP</td><td>125,844,844</td><td>台湾省 中华电信</td></tr>' & @CRLF & _
                '<tr><td>203.66.187.246<SCRIPT type=text/javascript>document.write(":"+r+c)</SCRIPT></td><td>HTTP</td><td>109,969,984</td><td>台湾省 中华电信</td></tr>' & @CRLF & _
                '<tr><td>207.211.86.196<SCRIPT type=text/javascript>document.write(":"+r+d)</SCRIPT></td><td>HTTP</td><td>219,875,875</td><td>United States</td></tr>' & @CRLF & _
                '<tr><td>41.35.48.30<SCRIPT type=text/javascript>document.write(":"+r+d+r+d)</SCRIPT></td><td>HTTP</td><td>500,1359,1390</td><td>Egypt</td></tr>' & @CRLF & _
                '<tr><td>41.43.31.134<SCRIPT type=text/javascript>document.write(":"+r+d+r+d)</SCRIPT></td><td>HTTP</td><td>641,1922,1953</td><td>Egypt</td></tr>' & @CRLF & _
                '<tr><td>41.215.247.146<SCRIPT type=text/javascript>document.write(":"+r+d+r+d)</SCRIPT></td><td>HTTP</td><td>594,1813,1813</td><td>尼日利亚</td></tr>' & @CRLF & _
                '<tr><td>68.71.76.242<SCRIPT type=text/javascript>document.write(":"+r+d+r+k)</SCRIPT></td><td>HTTP</td><td>266,1234,1250</td><td>United States</td></tr>' & @CRLF & _
                '<tr><td>80.75.15.157<SCRIPT type=text/javascript>document.write(":"+r+d+r+d)</SCRIPT></td><td>HTTP</td><td>516,1735,1750</td><td>Iran</td></tr>' & @CRLF & _
                '<tr><td>112.217.228.212<SCRIPT type=text/javascript>document.write(":"+r+d+r+d)</SCRIPT></td><td>HTTP</td><td>156,1000,1140</td><td>Korea</td></tr>' & @CRLF & _
                '<tr><td>115.124.69.58<SCRIPT type=text/javascript>document.write(":"+r+d)</SCRIPT></td><td>HTTP</td><td>375,1453,1468</td><td>印度尼西亚 雅加达市</td></tr>' & @CRLF & _
                '<tr><td>116.90.211.136<SCRIPT type=text/javascript>document.write(":"+r+d+r+d)</SCRIPT></td><td>HTTP</td><td>313,1313,1328</td><td>Indonesia</td></tr>' & @CRLF & _
                '<tr><td>118.96.153.254<SCRIPT type=text/javascript>document.write(":"+r+d+r+d)</SCRIPT></td><td>HTTP</td><td>453,1656,1687</td><td>Indonesia</td></tr>' & @CRLF & _
                '<tr><td>118.97.71.57<SCRIPT type=text/javascript>document.write(":"+r+d+r+d)</SCRIPT></td><td>HTTP</td><td>219,1016,1016</td><td>Indonesia</td></tr>' & @CRLF & _
                '<tr><td>118.97.170.195<SCRIPT type=text/javascript>document.write(":"+r+d+r+d)</SCRIPT></td><td>HTTP</td><td>343,1203,1750</td><td>Indonesia</td></tr>' & @CRLF & _
                '<tr><td>118.97.221.53<SCRIPT type=text/javascript>document.write(":"+r+d+r+d)</SCRIPT></td><td>HTTP</td><td>375,1406,1797</td><td>Indonesia</td></tr>' & @CRLF & _
                '<tr><td>122.200.54.42<SCRIPT type=text/javascript>document.write(":"+r+d)</SCRIPT></td><td>HTTP</td><td>485,1719,1719</td><td>Indonesia</td></tr>' & @CRLF & @CRLF
;MsgBox(0, '原字符串', $Str)

Local $sTest = StringRegExpReplace($Str, '<.+?>', @TAB)
$Str = StringRegExpReplace($sTest, '(?<=^|\n)\t\t(?:\D\V+\v+)?', '')

Local $sCode = 'z="3";m="4";k="2";l="9";d="0";b="5";i="7";w="6";r="8";c="1"'
Local $aSR = StringRegExp($sCode, '(\w)\="(\d+)', 3)
For $i = 0 To UBound($aSR) - 1 Step 2
        $Str = StringReplace($Str, '+' & $aSR[$i], $aSR[$i + 1])
Next
$Str = StringRegExpReplace($Str, '(?i)document\.write\(":"([^\)]+)\)', '$1')

MsgBox(0, '结果', $Str)

评分

参与人数 2金钱 +117 贡献 +5 收起 理由
auto + 87 + 5 谢谢帮忙
Duvet + 30 ^^

查看全部评分

发表于 2012-6-17 00:13:00 | 显示全部楼层
貌似是这个网站的 哈哈 以前采集过www_cz88_net
发表于 2012-6-17 00:34:45 | 显示全部楼层

Opt("ExpandVarStrings", 1)
Local $d = 0, $c = 1, $k = 2, $z = 3, $m = 4, $b = 5, $w = 6, $i = 7, $r = 8, $l = 9
Local $Text = ClipGet()
$Text = StringRegExpReplace($Text, '\A.+\s+|<.+?>|doc[^:]+:"', '')
$Text = StringRegExpReplace($Text, '(?<=\d)(?=[^\d.,])|[)]', @TAB)
$Text = StringRegExpReplace($Text, "\+([dckzmbwirl])", '$\1$')
MsgBox(0, "Result :", $Text)

评分

参与人数 3威望 +5 金钱 +202 贡献 +20 收起 理由
auto + 87 + 5 很棒的见解
user3000 + 15 + 5 好思路哇!
afan + 5 + 100 + 10 ^ ^

查看全部评分

发表于 2012-6-17 01:24:14 | 显示全部楼层
Duvet 发表于 2012-6-17 00:34



    大师威武

评分

参与人数 1金钱 +60 贡献 +15 收起 理由
魔导 + 60 + 15 膜拜A大的精神

查看全部评分

发表于 2012-6-17 17:22:37 | 显示全部楼层
回复 7# afan

您谦虚了。在ACN上,您的学习精神与无私奉献,才称的上是大师啊!这是众人认定的。
发表于 2012-6-21 11:19:55 | 显示全部楼层
我也来凑个热闹呢。

#include <array.au3>

Local $z="3",$m="4",$k="2",$l="9",$d="0",$b="5",$i="7",$w="6",$r="8",$c="1"

Local $str = _
'<tr><td width="140">IP:Port</td><td width="40">Type</td><td width="90">Speed</td><td width="160"> Country/Area</td></tr>' & @crlf & _
'<tr><td>119.82.252.7<SCRIPT type=text/javascript>document.write(":"+r+d+r+d)</SCRIPT></td><td>HTTP</td><td>219,938,938</td><td>柬埔寨</td></tr>' & @crlf & _
'<tr><td>202.43.179.182<SCRIPT type=text/javascript>document.write(":"+b+m+z+k+c)</SCRIPT></td><td>HTTP</td><td>187,953,953</td><td>印度尼西亚 MORA电信</td></tr>' & @crlf & _
'<tr><td>202.171.253.98<SCRIPT type=text/javascript>document.write(":"+r+d)</SCRIPT></td><td>HTTP</td><td>78,375,375</td><td>澳门 Macauweb公司</td></tr>' & @crlf & _
'<tr><td>203.66.187.246<SCRIPT type=text/javascript>document.write(":"+r+d)</SCRIPT></td><td>HTTP</td><td>125,844,844</td><td>台湾省 中华电信</td></tr>' & @crlf & _
'<tr><td>203.66.187.246<SCRIPT type=text/javascript>document.write(":"+r+c)</SCRIPT></td><td>HTTP</td><td>109,969,984</td><td>台湾省 中华电信</td></tr>' & @crlf & _
'<tr><td>207.211.86.196<SCRIPT type=text/javascript>document.write(":"+r+d)</SCRIPT></td><td>HTTP</td><td>219,875,875</td><td>United States</td></tr>' & @crlf & _
'<tr><td>41.35.48.30<SCRIPT type=text/javascript>document.write(":"+r+d+r+d)</SCRIPT></td><td>HTTP</td><td>500,1359,1390</td><td>Egypt</td></tr>' & @crlf & _
'<tr><td>41.43.31.134<SCRIPT type=text/javascript>document.write(":"+r+d+r+d)</SCRIPT></td><td>HTTP</td><td>641,1922,1953</td><td>Egypt</td></tr>' & @crlf & _
'<tr><td>41.215.247.146<SCRIPT type=text/javascript>document.write(":"+r+d+r+d)</SCRIPT></td><td>HTTP</td><td>594,1813,1813</td><td>尼日利亚</td></tr>' & @crlf & _
'<tr><td>68.71.76.242<SCRIPT type=text/javascript>document.write(":"+r+d+r+k)</SCRIPT></td><td>HTTP</td><td>266,1234,1250</td><td>United States</td></tr>' & @crlf & _
'<tr><td>80.75.15.157<SCRIPT type=text/javascript>document.write(":"+r+d+r+d)</SCRIPT></td><td>HTTP</td><td>516,1735,1750</td><td>Iran</td></tr>' & @crlf & _
'<tr><td>112.217.228.212<SCRIPT type=text/javascript>document.write(":"+r+d+r+d)</SCRIPT></td><td>HTTP</td><td>156,1000,1140</td><td>Korea</td></tr>' & @crlf & _
'<tr><td>115.124.69.58<SCRIPT type=text/javascript>document.write(":"+r+d)</SCRIPT></td><td>HTTP</td><td>375,1453,1468</td><td>印度尼西亚 雅加达市</td></tr>' & @crlf & _
'<tr><td>116.90.211.136<SCRIPT type=text/javascript>document.write(":"+r+d+r+d)</SCRIPT></td><td>HTTP</td><td>313,1313,1328</td><td>Indonesia</td></tr>' & @crlf & _
'<tr><td>118.96.153.254<SCRIPT type=text/javascript>document.write(":"+r+d+r+d)</SCRIPT></td><td>HTTP</td><td>453,1656,1687</td><td>Indonesia</td></tr>' & @crlf & _
'<tr><td>118.97.71.57<SCRIPT type=text/javascript>document.write(":"+r+d+r+d)</SCRIPT></td><td>HTTP</td><td>219,1016,1016</td><td>Indonesia</td></tr>' & @crlf & _
'<tr><td>118.97.170.195<SCRIPT type=text/javascript>document.write(":"+r+d+r+d)</SCRIPT></td><td>HTTP</td><td>343,1203,1750</td><td>Indonesia</td></tr>' & @crlf & _
'<tr><td>118.97.221.53<SCRIPT type=text/javascript>document.write(":"+r+d+r+d)</SCRIPT></td><td>HTTP</td><td>375,1406,1797</td><td>Indonesia</td></tr>' & @crlf & _
'<tr><td>122.200.54.42<SCRIPT type=text/javascript>document.write(":"+r+d)</SCRIPT></td><td>HTTP</td><td>485,1719,1719</td><td>Indonesia</td></tr>' & @crlf

Local $exp1 = StringRegExp($str,'(?<=<td>)[^<>]+(?=<)|(?<=write\(":"\+)[^\)]+(?=\))',3)
;Local $exp2 = StringRegExp($str,'(?<=write\(":"\+)[^\)]+(?=\))',3)

_ArrayDisplay($exp1,UBound($exp1))

Local $i
Local $aData[UBound($exp1)]
Local $n = 0

For $i = 0 To UBound($exp1) - 1 Step 5
        $aData[$n] = $exp1[$i]
        Local $temp1 = StringRegExpReplace($exp1[$i+1],'\w','$$0')
        Local $temp2 = StringRegExpReplace($temp1,'\+','&')
        $aData[$n+1] = Execute($temp2)
        $aData[$n+2] = $exp1[$i+2]
        $aData[$n+3] = $exp1[$i+3]
        $aData[$n+4] = $exp1[$i+4]
        $n = $n + 5
Next
_ArrayDisplay($aData,UBound($aData))
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-11-18 23:40 , Processed in 0.096772 second(s), 29 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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