Reg ex Match

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
fedek
Posts: 60
Joined: 17 May 2016, 12:17
Contact:

Reg ex Match

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
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: Reg ex Match

08 Apr 2017, 16:06

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]
fedek
Posts: 60
Joined: 17 May 2016, 12:17
Contact:

Re: Reg ex Match

09 Apr 2017, 04:39

It founds only the first :/
User avatar
Spawnova
Posts: 557
Joined: 08 Jul 2015, 00:12
Contact:

Re: Reg ex Match

09 Apr 2017, 05:12

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
IMEime
Posts: 750
Joined: 20 Sep 2014, 06:15

Re: Reg ex Match

09 Apr 2017, 07:32

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
fedek
Posts: 60
Joined: 17 May 2016, 12:17
Contact:

Re: Reg ex Match

09 Apr 2017, 08:37

Many thanks

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Darkmaster006, GEOVAN, Giresharu, peter_ahk and 111 guests