求个正则表达式
打算做网页采集,在一个页面中有很多网址,如:http://www.xx.com/id?=01http://www.xx.com/id?=02
http://www.xx.com/id?=03
http://www.xx.com/id?=01
http://www.xx.com/id?=02
http://www.xx.com/id?=05
http://www.xx.com/id?=01
http://www.xx.com/id?=08
列表页面很多网址,这里面很多重复的,正则不是很熟练,如:http://www.xx.com/id?=01正则获取网址的时候这个重复3次都符合规则,这就造成了后面采集http://www.xx.com/id?=01页面内容的时候就重复采集了3次,现在想用正则,在获取这些网址的时候就过滤掉重复项,只保留一个有效的,不知道有没有这样的正则表达式?
求大大们指点迷津~ Local $Str = _
'http://www.xx.com/id?=01' & @CRLF & _
'http://www.xx.com/id?=01' & @CRLF & _
'http://www.xx.com/id?=02' & @CRLF & _
'http://www.xx.com/id?=03 ' & @CRLF & _
'http://www.xx.com/id?=01 ' & @CRLF & _
'http://www.xx.com/id?=02' & @CRLF & _
'http://www.xx.com/id?=05' & @CRLF & _
'http://www.xx.com/id?=04' & @CRLF & _
'http://www.xx.com/id?=01 1' & @CRLF & _
'http://www.xx.com/id?=08' & @CRLF & _
'http://www.xx.com/id?=05 '
MsgBox(0, '原字符串', $Str)
Local $sRE = StringRegExpReplace($str, '(?m)(^\V+)(?:\s*\v+)(?=[^\1]*\1\s*(?=\v|$))', '')
MsgBox(0, '替换结果', $sRE)
页:
[1]