找回密码
 加入
搜索
查看: 6821|回复: 13

[效率算法] 正则匹配 标题

 火.. [复制链接]
发表于 2011-4-25 14:02:10 | 显示全部楼层 |阅读模式
本帖最后由 haodd 于 2011-4-25 15:25 编辑

正则匹配的内容
正则匹配 的内容
就是搜索的关键字


当搜索为 “我的团长我的团” 时 取到“我的团长我的团”

我就是像取到关键字 而不是 定式的取文本 “正则匹配的内容” | “正则匹配 的内容”
正则匹配的内容_淘宝搜索 - Microsoft Internet Explorer
正则匹配的内容_网页搜索 - Microsoft Internet Explorer
狗狗搜索-正则匹配的内容 - Microsoft Internet Explorer
正则匹配的内容 - 必应 Bing - Microsoft Internet Explorer
正则匹配的内容 - Google 搜索 - Microsoft Internet Explorer
正则匹配的内容?-?搜狗搜索 - Microsoft Internet Explorer
正则匹配的内容 - 有道搜索 - Microsoft Internet Explorer
正则匹配的内容 - 搜搜更懂你 - Microsoft Internet Explorer
百度搜索_正则匹配的内容 - Microsoft Internet Explorer
以上是文本(部分1)
需要匹配出(部分1中 不管取到哪一行都匹配出)
正则匹配的内容
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
正则匹配 的内容_淘宝搜索 - Microsoft Internet Explorer
正则匹配 的内容_网页搜索 - Microsoft Internet Explorer
狗狗搜索-正则匹配 的内容 - Microsoft Internet Explorer
正则匹配 的内容 - 必应 Bing - Microsoft Internet Explorer
正则匹配 的内容 - Google 搜索 - Microsoft Internet Explorer
正则匹配 的内容?-?搜狗搜索 - Microsoft Internet Explorer
正则匹配 的内容 - 有道搜索 - Microsoft Internet Explorer
正则匹配 的内容 - 搜搜更懂你 - Microsoft Internet Explorer
百度搜索_正则匹配 的内容 - Microsoft Internet Explorer
以上是文本(部分2)
需要匹配出(部分2中 不管取到哪一行都匹配出)
正则匹配 的内容
正则不懂唉,昨天晚上一直发不了帖子!
发表于 2011-4-25 14:40:13 | 显示全部楼层
窃以为 单用正则不妥 建立一个各搜索引擎的关键词数组吧 然后再用正则或者字符串函数处理都很简单 反正也没几个
发表于 2011-4-25 14:48:47 | 显示全部楼层
本帖最后由 lixiaolong 于 2011-4-25 14:51 编辑

不知道这样对不对?

部分1
StringRegExp($str, '正则匹配的内容', 3)

部分2
StringRegExp($str, '正则匹配 的内容, 3)
 楼主| 发表于 2011-4-25 15:00:15 | 显示全部楼层
回复 3# lixiaolong


    龙哥的答案很明显是正确的

但是
正则匹配 的内容
正则匹配的内容


是要匹配出来的 是未知的!
发表于 2011-4-25 15:15:57 | 显示全部楼层
回复 4# haodd


    不大明白楼主的意思,是不是这样的:

StringRegExp($str, '正则匹配的内容|正则匹配 的内容, 3)
发表于 2011-4-25 15:56:10 | 显示全部楼层
哪里有那么复杂
(正则.*?内容)(.*)
看看是不是这个效果,是的话 我上代码
发表于 2011-4-25 17:09:40 | 显示全部楼层
回复 6# love5173

上吧!
发表于 2011-4-26 19:22:42 | 显示全部楼层
本帖最后由 love5173 于 2011-4-26 20:28 编辑

处理文本
我叫mt_淘宝搜索 - Microsoft Internet Explorer
我叫mt_网页搜索 - Microsoft Internet Explorer
狗狗搜索-我叫mt - Microsoft Internet Explorer
我叫mt - 必应 Bing - Microsoft Internet Explorer
我叫mt - Google 搜索 - Microsoft Internet Explorer
我叫mt?-?搜狗搜索 - Microsoft Internet Explorer
我叫mt - 有道搜索 - Microsoft Internet Explorer
我叫mt - 搜搜更懂你 - Microsoft Internet Explorer
百度搜索_我叫mt - Microsoft Internet Explorer

我叫mt 第四季_淘宝搜索 - Microsoft Internet Explorer
我叫mt 第四季_网页搜索 - Microsoft Internet Explorer
狗狗搜索-我叫mt 第四季 - Microsoft Internet Explorer
我叫mt 第四季 - 必应 Bing - Microsoft Internet Explorer
我叫mt 第四季 - Google 搜索 - Microsoft Internet Explorer
我叫mt 第四季?-?搜狗搜索 - Microsoft Internet Explorer
我叫mt 第四季 - 有道搜索 - Microsoft Internet Explorer
我叫mt 第四季 - 搜搜更懂你 - Microsoft Internet Explorer
百度搜索_我叫mt 第四季 - Microsoft Internet Explorer
#include <Array.au3>
FileOpen("D:\UserFile\Desktop\1.txt",0)
$txt=FileRead("D:\UserFile\Desktop\1.txt")
FileClose("D:\UserFile\Desktop\1.txt")
$array=StringRegExp ($txt,'(?:狗狗|百度)搜索[-_]([^_-]*?)\h+\-.*\n|([^-_\?]+)[^\n]+\n',3)
_ArrayDisplay ($array)

我真的是水平有限,怎么表达能避免空行出现啊!!!!!!!
发表于 2011-4-26 20:36:15 | 显示全部楼层
本帖最后由 love5173 于 2011-4-26 20:38 编辑

#include <Array.au3>
FileOpen("D:\UserFile\Desktop\1.txt",0)
$txt=FileRead("D:\UserFile\Desktop\1.txt")
FileClose("D:\UserFile\Desktop\1.txt")
$txt1=StringRegExpReplace($txt,'((?:狗狗|百度)搜索)([-_])([^_-]*?)(\h+\-.*\n)','\3\2\1\4) 
$array=StringRegExp ($txt1,'([^-_\?]+)[^\n]+\n',3)
_ArrayDisplay ($array)

虽然解决了,但是总感觉很牵强
发表于 2011-4-26 21:04:22 | 显示全部楼层
。。。正则也不是万能的,不要什么都找 正则
发表于 2011-4-26 21:09:13 | 显示全部楼层
回复 10# lluxury
其实楼主不排斥你用别的方法实现类似功能,欢迎你上代码
发表于 2011-4-26 22:05:44 | 显示全部楼层
说实话真没看懂楼主想要表达什么?
来来回回看了好几遍,愣没看懂.
是取窗口关键字吗?那么多标签的时候怎么取呢?
发表于 2011-4-26 22:39:52 | 显示全部楼层
回复 12# 3mile
楼主用的其他软件截获内网机器的上网记录,楼主想知道分机到底用搜索引擎搜索了什么内容,不想知道是用什么搜索引擎或者浏览器搜索的。
我是加了他Q聊了很久才明白怎么回事的!
发表于 2011-4-26 22:57:41 | 显示全部楼层
本帖最后由 lluxury 于 2011-4-26 23:01 编辑
回复  lluxury
其实楼主不排斥你用别的方法实现类似功能,欢迎你上代码
love5173 发表于 2011-4-26 21:09



    ...哥哥我又没得罪你。。我还找人教我固定连接怎么点击呢

不过我觉得,用excel的表格功能可以取出来,以-做分隔的话
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-2 05:05 , Processed in 0.082637 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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