Reg ex Match
Posted: 08 Apr 2017, 15:42
There is a part on a page. Guys, please help me to get id from this (316977). Here are any ids in the page, so it shoul take all of them.
Spoiler
Let's help each other out
https://www.autohotkey.com/boards/
https://www.autohotkey.com/boards/viewtopic.php?f=76&t=30305
Code: Select all
haystack=
(
<td class='normal' colspan='3'>
<center>
<span id='dyn_none316977' >
<a onClick="start_surfing('http://add.seo-fast.ru/viewing_surfing?id=316977', '316977'); " target='_blank' ><img class='img_ban_s' src='https://vesworld.com/img/baneri/468.gif' width='468' height='60'></a>
</center>
</span>
</td>
)
needle:="O)', '(\d+)'\);"
RegExMatch(haystack,needle,match)
MsgBox, % match[1]
Code: Select all
haystack=
(
<td class='normal' colspan='3'>
<center>
<span id='dyn_none316977' >
<a onClick="start_surfing('http://add.seo-fast.ru/viewing_surfing?id=316977', '316977'); " target='_blank' ><img class='img_ban_s' src='https://vesworld.com/img/baneri/468.gif' width='468' height='60'></a>
</center>
</span>
</td>
<td class='normal' colspan='3'>
<center>
<span id='dyn_none525363' >
<a onClick="start_surfing('http://add.seo-fast.ru/viewing_surfing?id=316977', '525363'); " target='_blank' ><img class='img_ban_s' src='https://vesworld.com/img/baneri/468.gif' width='468' height='60'></a>
</center>
</span>
</td>
<td class='normal' colspan='3'>
<center>
<span id='dyn_none152637' >
<a onClick="start_surfing('http://add.seo-fast.ru/viewing_surfing?id=316977', '152637'); " target='_blank' ><img class='img_ban_s' src='https://vesworld.com/img/baneri/468.gif' width='468' height='60'></a>
</center>
</span>
</td>
)
needle := "dyn_none(\d+)" ;needle := "',\s'(\d+)'\)" ;if the id does not always start with dyn_none then use this commented out needle instead
while cPos := RegExMatch(haystack,needle,match,cPos?cPos+1:1) {
msgbox % "Found match at position: " cPos "`nValue = " match1
}
exitapp
Code: Select all
C =
(
<td class='normal' colspan='3'>
<center>
<span id='dyn_none316977' >
<a onClick="start_surfing('http://add.seo-fast.ru/viewing_surfing?id=316977', '316977'); " target='_blank' ><img class='img_ban_s' src='https://vesworld.com/img/baneri/468.gif' width='468' height='60'></a>
</center>
</span>
</td>
<td class='normal' colspan='3'>
<center>
<span id='dyn_none525363' >
<a onClick="start_surfing('http://add.seo-fast.ru/viewing_surfing?id=316977', '525363'); " target='_blank' ><img class='img_ban_s' src='https://vesworld.com/img/baneri/468.gif' width='468' height='60'></a>
</center>
</span>
</td>
<td class='normal' colspan='3'>
<center>
<span id='dyn_none152637' >
<a onClick="start_surfing('http://add.seo-fast.ru/viewing_surfing?id=316977', '152637'); " target='_blank' ><img class='img_ban_s' src='https://vesworld.com/img/baneri/468.gif' width='468' height='60'></a>
</center>
</span>
</td>
)
_ := ComObjCreate( "VBScript.RegExp" )
_.Global := -1
_.Pattern := "dyn_none(\d+)"
For m In _.Execute(C)
r .= m.Submatches(0) "`n"
MsgBox % r