正则问题,如何匹配URLEncode编码
;nick=%E6%9C%B5%E6%8B%89%E6%9C%B5%E5%B0%9A%E6%97%97%E8%88%B0%E5%BA%97&type=big&sid=efd1dd1d8e6f780cde9a56d56f522034" /></a>nickName: '%E6%B8%B8%E6%88%8F%E4%BB%99%E4%BA%BA',(?:%\w{2})+
可以匹配
但是我只需要前置是 nickName|nick的
匹配结果是
%E6%9C%B5%E6%8B%89%E6%9C%B5%E5%B0%9A%E6%97%97%E8%88%B0%E5%BA%97
%E6%B8%B8%E6%88%8F%E4%BB%99%E4%BA%BA (?<=nick\=|nickName: ')(?:%\w{2})+这个貌似可以 没太弄明白! #include <Array.au3>
Local $Str = _
'nick=%E6%9C%B5%E6%8B%89%E6%9C%B5%E5%B0%9A%E6%97%97%E8%88%B0%E5%BA%97&type=big&sid=efd1dd1d8e6f780cde9a56d56f522034" /></a>' & @CRLF & _
"nickName: '%E6%B8%B8%E6%88%8F%E4%BB%99%E4%BA%BA',"
Local $Test = StringRegExp($str, 'nick(?:Name)?[^%]*((?:%\w{2})+)', 3)
_ArrayDisplay($Test)
谢谢了谢谢 本帖最后由 小影 于 2012-12-25 15:47 编辑
回复 2# heavenm
(?<=nick\=|nickName: ')(?:%\w{2})+
;以nick\=|nickName: ' --向后断言匹配非获捕组(组内容为:%\w{2})的内容重复至少一次以上
或者用如下代码也可行,
#include <Array.au3>
Local $Str = _
'nick=%E6%9C%B5%E6%8B%89%E6%9C%B5%E5%B0%9A%E6%97%97%E8%88%B0%E5%BA%97&type=big&sid=efd1dd1d8e6f780cde9a56d56f522034" /></a>' & @CRLF & _
"nickName: '%E6%B8%B8%E6%88%8F%E4%BB%99%E4%BA%BA',"
Local $Test = StringRegExp($str, "(?<=k\=|')(.+?)(?=\&|')", 3)
_ArrayDisplay($Test)
页:
[1]