haodd 发表于 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中 不管取到哪一行都匹配出)正则匹配 的内容
正则不懂唉,昨天晚上一直发不了帖子!{:face (396):}

大绯狼 发表于 2011-4-25 14:40:13

窃以为 单用正则不妥 建立一个各搜索引擎的关键词数组吧 然后再用正则或者字符串函数处理都很简单 反正也没几个

lixiaolong 发表于 2011-4-25 14:48:47

本帖最后由 lixiaolong 于 2011-4-25 14:51 编辑

不知道这样对不对?

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

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

haodd 发表于 2011-4-25 15:00:15

回复 3# lixiaolong


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

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


是要匹配出来的 是未知的!{:face (245):}

papapa314 发表于 2011-4-25 15:15:57

回复 4# haodd


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

StringRegExp($str, '正则匹配的内容|正则匹配 的内容, 3)

love5173 发表于 2011-4-25 15:56:10

哪里有那么复杂
(正则.*?内容)(.*)
看看是不是这个效果,是的话 我上代码

水木子 发表于 2011-4-25 17:09:40

回复 6# love5173

上吧!{:face (447):}

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)
我真的是水平有限,怎么表达能避免空行出现啊!!!!!!!

love5173 发表于 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)
虽然解决了,但是总感觉很牵强

lluxury 发表于 2011-4-26 21:04:22

。。。正则也不是万能的,不要什么都找 正则

love5173 发表于 2011-4-26 21:09:13

回复 10# lluxury
其实楼主不排斥你用别的方法实现类似功能,欢迎你上代码

3mile 发表于 2011-4-26 22:05:44

说实话真没看懂楼主想要表达什么?
来来回回看了好几遍,愣没看懂.
是取窗口关键字吗?那么多标签的时候怎么取呢?

love5173 发表于 2011-4-26 22:39:52

回复 12# 3mile
楼主用的其他软件截获内网机器的上网记录,楼主想知道分机到底用搜索引擎搜索了什么内容,不想知道是用什么搜索引擎或者浏览器搜索的。
我是加了他Q聊了很久才明白怎么回事的!

lluxury 发表于 2011-4-26 22:57:41

本帖最后由 lluxury 于 2011-4-26 23:01 编辑

回复lluxury
其实楼主不排斥你用别的方法实现类似功能,欢迎你上代码
love5173 发表于 2011-4-26 21:09 http://autoitx.com/images/common/back.gif


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

不过我觉得,用excel的表格功能可以取出来,以-做分隔的话
页: [1]
查看完整版本: 正则匹配 标题