Page 1 of 1

Reg ex Match

Posted: 08 Apr 2017, 15:42
by fedek
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

Re: Reg ex Match

Posted: 08 Apr 2017, 16:06
by Helgef
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

Posted: 09 Apr 2017, 04:39
by fedek
It founds only the first :/

Re: Reg ex Match

Posted: 09 Apr 2017, 05:12
by Spawnova
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

Re: Reg ex Match

Posted: 09 Apr 2017, 07:32
by IMEime
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

Posted: 09 Apr 2017, 08:37
by fedek
Many thanks