Spoiler
Reg ex Match
Reg ex Match
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.
Re: Reg ex Match
Try this,
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]
Re: Reg ex Match
It founds only the first :/
Re: Reg ex Match
With some tweaking it is easy to capture multiple instances
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
Some of my AHK programs: 3D Voxel Game - Platformer Game
GitHub projects : Image/Pixel scanning class - Direct2D overlay class
GitHub projects : Image/Pixel scanning class - Direct2D overlay class
Re: Reg ex Match
With some tweaking (2).
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
Re: Reg ex Match
Many thanks