找回密码
 加入
搜索
查看: 3297|回复: 7

[AU3基础] 前辈帮忙处理大量文本内容,需要用正则!

  [复制链接]
发表于 2012-6-9 15:30:23 | 显示全部楼层 |阅读模式
本帖最后由 qixinwb 于 2012-6-9 20:58 编辑
<tr bgcolor=#fafafa onmouseover=this.bgColor='#eaeaf4'; onmouseout=this.bgColor='#fafafa';>
<td class="td3" style="text-align: center;" COLSPAN="8"><span CLASS="b red">武汉自驾车去·河北省·线路·里程</span></td>
</tr>

<tr bgcolor=#fafafa onmouseover=this.bgColor='#eaeaf4'; onmouseout=this.bgColor='#fafafa';>


<td class="td3" style="text-align: center; background: #e8f7ff;">石家庄</td>
        <td style="text-align: center"><a TARGET="_blank" [b]href="http://www.checi.cn/way_to/wuhan/39/">武汉到石家庄线路</a></td>
        <td style="text-align: center">896千米</td>
        <td style="text-align: center">11小时43分钟</td>



<td class="td3" style="text-align: center; background: #e8f7ff;">唐山</td>
        <td style="text-align: center"><a TARGET="_blank"href="http://www.checi.cn/way_to/wuhan/63/">武汉到唐山线路</a></td>
        <td style="text-align: center">1,280千米</td>
        <td style="text-align: center">16小时56分钟</td>


</tr>

<tr bgcolor=#fafafa onmouseover=this.bgColor='#eaeaf4'; onmouseout=this.bgColor='#fafafa';>


<td class="td3" style="text-align: center; background: #e8f7ff;">秦皇岛</td>
        <td style="text-align: center"><a TARGET="_blank"href="http://www.checi.cn/way_to/wuhan/78/">武汉到秦皇岛线路</a></td>
        <td style="text-align: center">1,462千米</td>
        <td style="text-align: center">18小时17分钟</td>



<td class="td3" style="text-align: center; background: #e8f7ff;">邯郸</td>
        <td style="text-align: center"><a TARGET="_blank"href="http://www.checi.cn/way_to/wuhan/86/">武汉到邯郸线路</a></td>
        <td style="text-align: center">731千米</td>
        <td style="text-align: center">9小时35分钟</td>


</tr>

<tr bgcolor=#fafafa onmouseover=this.bgColor='#eaeaf4'; onmouseout=this.bgColor='#fafafa';>


<td class="td3" style="text-align: center; background: #e8f7ff;">邢台</td>
        <td style="text-align: center"><a TARGET="_blank" href="http://www.checi.cn/way_to/wuhan/106/">武汉到邢台线路</a></td>
        <td style="text-align: center">786千米</td>
        <td style="text-align: center">10小时24分钟</td>



<td class="td3" style="text-align: center; background: #e8f7ff;">保定</td>
        <td style="text-align: center"><a TARGET="_blank" href="http://www.checi.cn/way_to/wuhan/124/">武汉到保定线路</a></td>
        <td style="text-align: center">1,031千米</td>
        <td style="text-align: center">13小时33分钟</td>


</tr>
部分内容如上,我需要替换其中的所有的类似“href="http://www.checi.cn/way_to/wuhan/39/">武汉到石家庄线路”为“href="武汉到石家庄线路.html">武汉到石家庄线路”,依此类推、。。。
href="武汉到石家庄线路.html">武汉到石家庄线路
href="武汉到唐山线路.html">武汉到唐山线路
href="武汉到秦皇岛线路.html">武汉到秦皇岛线路
href="武汉到邯郸线路.html">武汉到邯郸线路
.......
附件是整个文档,简单的说,就是把top.txt里面一部分部分的替换成list.txt里面的

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2012-6-9 15:44:03 | 显示全部楼层
本帖最后由 Ycxw2008 于 2012-6-9 15:57 编辑

StringRegExpReplace(FileRead("C:\Users\Administrator\Desktop\top.txt.au3"),'(?<=<a TARGET="_blank" href=)([^\>]+\>)([^\<]+)',"bbx/$2\.html")

试试看
是这样吗
 楼主| 发表于 2012-6-9 16:46:09 | 显示全部楼层
我测试显示错误:Error:Unknown Function name。麻烦你再上传编译好的exe我试试看?莫非是我的版本问题
发表于 2012-6-9 20:25:24 | 显示全部楼层
Local $Str = FileRead('top.txt')
Local $sTest = StringRegExpReplace($str, '(?<=href=")[^"]+">(.+?)(?=</a)', 'bbx/$1.html">$1')
FileWrite('top_修改.txt', $sTest)
 楼主| 发表于 2012-6-9 21:04:44 | 显示全部楼层
望尘莫及!。。。
发表于 2012-6-9 21:07:58 | 显示全部楼层
望尘莫及!。。。
qixinwb 发表于 2012-6-9 21:04



    何出此言?
 楼主| 发表于 2012-6-9 21:21:31 | 显示全部楼层
实在是佩服,找你果然正确
 楼主| 发表于 2012-6-9 22:30:59 | 显示全部楼层
回复 6# afan


   
好不容易把那个看懂了,不过新难题又来了。。。
这回是两处要替换,完全没有头绪了。。。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-3 07:42 , Processed in 0.081989 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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