【已解决】又遇到正则问题,有办法取得图片中那种数据麽?
本帖最后由 huangke 于 2013-1-22 21:21 编辑<DIV id=content class=content mod-cs-content text-content clearfix>
<P><SPAN>2013/01/30</SPAN></P>
<P><SPAN><SPAN>2013/05/30</SPAN><BR></SPAN></P>
<P><SPAN><SPAN><SPAN>2013/12/30</SPAN><BR></SPAN></SPAN></P>
<P><SPAN><SPAN><SPAN><SPAN>2014/01/01</SPAN><BR></SPAN></SPAN></SPAN></P>
<P><SPAN><SPAN><SPAN><SPAN><SPAN>2013/06/01</SPAN><BR></SPAN></SPAN></SPAN></SPAN></P>
<P><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN>2014/01/01</SPAN></SPAN><BR></SPAN></SPAN></SPAN></SPAN></SPAN></P>
<P><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN>2014/06/01</SPAN><BR></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></P>
<P><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN>2014/12/01</SPAN><BR></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></P>
<P><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN>2015/01/01</SPAN><BR></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></P>
<P><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN>2015/06/01</SPAN></SPAN><BR></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></P>
<P><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN>2015/12/01</SPAN></SPAN><BR></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></P>
<P><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN>2016/01/01</SPAN><BR></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></P>
<P><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN>1</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></P>
<P><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN>2</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></P>
<P><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN>3</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></P>
<P><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN>4</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></P>
<P><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN>5</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></P>
<P><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN>6</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></P>
<P><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN>7</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></P>
<P><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN>8</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></P>
<P><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN>9</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></P>
<P><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN>10</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></P></DIV>
<DIV class=mod-tagbox clearfix>
上面数据是网页中取得的源代码,想取得里面的一些数据,毫无头绪ING。。。。。。。{:face (87):}知道用 StringRegExp,看来得花时间看看 ?.()等奇怪的符号了。
如何取得下面的数据:(就是<span></span>里面的值,但是很多<span>与</span>是木有匹配的。)2013/01/302013/05/302013/12/302014/01/012013/06/012014/01/012014/06/012014/12/012015/01/012015/06/012015/12/012016/01/0112345678910 (?i)SPAN>([\d\/]+) >([\d\/]+) 本帖最后由 lpxx 于 2013-1-22 20:25 编辑
简单点,去除html标签就行了StringRegExpReplace($str, '<[^>]*>', '', 0) 楼上的大牛,牛逼!强大!回去学正则,发奋呐!
afan 发表于 2013-1-22 18:00 http://www.autoitx.com/images/common/back.gif
afan这个是相反了,数据去掉了。。。留下很多标签,数据不见鸟 本帖最后由 afan 于 2013-1-22 22:07 编辑
afan这个是相反了,数据去掉了。。。留下很多标签,数据不见鸟
huangke 发表于 2013-1-22 21:54 http://www.autoitx.com/images/common/back.gif
你不是要“取到”某某数据吗? 一般来说,用 StringRegExp() 来取匹配的数据。
当然,也可以用 StringRegExpReplace() 来剔取,如果需要整体使用获取的数据的话。
正则有匹配和替换两种形式,可根据需要选择高效、适合使用的方式。
比如上面获取的 2013/01/30、2013/05/30、…… 需要单独使用(如列表显示)则适合使用匹配方式;需要整体使用(如输出Txt文档)则适合使用替换方式。 你不是要“取到”某某数据吗? 一般来说,用 StringRegExp() 来取匹配的数据。
当然,也可以用...
afan 发表于 2013-1-22 22:00 http://www.autoitx.com/images/common/back.gif
哦哦,我搞错了。。。A版的木有错,我错了。。。。
$array = StringRegExp($html, '(?i)SPAN>([\d\/]+)', 3)
_ArrayDisplay($array) afan这个是相反了,数据去掉了。。。留下很多标签,数据不见鸟
huangke 发表于 2013-1-22 21:54 http://www.autoitx.com/images/common/back.gif
适用例子#include <Array.au3>
Local $Str = _
'<DIV id=content class=content mod-cs-content text-content clearfix>' & @CRLF & _
'<P><SPAN>2013/01/30</SPAN></P>' & @CRLF & _
'<P><SPAN><SPAN>2013/05/30</SPAN><BR></SPAN></P>' & @CRLF & _
'<P><SPAN><SPAN><SPAN>2013/12/30</SPAN><BR></SPAN></SPAN></P>' & @CRLF & _
'<P><SPAN><SPAN><SPAN><SPAN>2014/01/01</SPAN><BR></SPAN></SPAN></SPAN></P>' & @CRLF & _
'<P><SPAN><SPAN><SPAN><SPAN><SPAN>2013/06/01</SPAN><BR></SPAN></SPAN></SPAN></SPAN></P>' & @CRLF & _
'<P><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN>2014/01/01</SPAN></SPAN><BR></SPAN></SPAN></SPAN></SPAN></SPAN></P>' & @CRLF & _
'<P><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN>2014/06/01</SPAN><BR></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></P>' & @CRLF & _
'<P><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN>2014/12/01</SPAN><BR></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></P>' & @CRLF & _
'<P><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN>2015/01/01</SPAN><BR></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></P>' & @CRLF & _
'<P><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN>2015/06/01</SPAN></SPAN><BR></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></P>' & @CRLF & _
'<P><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN>2015/12/01</SPAN></SPAN><BR></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></P>' & @CRLF & _
'<P><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN>2016/01/01</SPAN><BR></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></P>' & @CRLF & _
'<P><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN>1</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></P>' & @CRLF & _
'<P><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN>2</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></P>' & @CRLF & _
'<P><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN>3</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></P>' & @CRLF & _
'<P><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN>4</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></P>' & @CRLF & _
'<P><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN>5</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></P>' & @CRLF & _
'<P><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN>6</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></P>' & @CRLF & _
'<P><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN>7</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></P>' & @CRLF & _
'<P><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN>8</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></P>' & @CRLF & _
'<P><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN>9</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></P>' & @CRLF & _
'<P><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN><SPAN>10</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></P></DIV>' & @CRLF & _
'<DIV class=mod-tagbox clearfix>'
Local $Test = StringRegExp($str, '(?i)SPAN>([\d\/]+)', 3)
If @Error Then Exit
_ArrayDisplay($Test, '列表需要')
Local $Test1 = StringRegExpReplace($str, '<.*?>', '')
MsgBox(0, '整体需要', $Test1) {:face (427):}哈哈,强强强,,,收下,猛学习!
页:
[1]