how to change it to AHK_H V2 from AHK_L

Ask for help, how to use AHK_H, etc.
xuezhe
Posts: 91
Joined: 06 Jan 2016, 11:02

how to change it to AHK_H V2 from AHK_L

06 Oct 2017, 04:05

Code: Select all

test := RegExMatches("12_567", "\d+")
Msgbox  % test[1] "," test[2] ; --> 12,567 

test := RegExMatches("12_567", "\d(\d+)", 1) ; 取得子匹配 1 的结果
Msgbox % test[1] "," test[2] ; --> 2,67 


RegExMatches(ByRef Haystack, NeedleRegEx, SubPat:="")
{   
	 arr := [], startPos := 1   
	 while ( pos := RegExMatch(Haystack, NeedleRegEx, match, startPos) )
	  {  
	     arr.push(match%SubPat%)    
	     startPos := pos + StrLen(match) 
	  }    
	 return arr.MaxIndex() ? arr : ""
 }
it doesn't works in AHK_H V2 ,but it works well in AHK_L.
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: how to change it to AHK_H V2 from AHK_L

06 Oct 2017, 05:49

Your function doesn't work in either of the latest L and H v2 versions. Single % to force expressions are removed. Regexmatch now outputs match objects by default. Example for your function,

Code: Select all

test := RegExMatches("12_567", "\d+")
Msgbox  test[1] "," test[2] ; --> 12,567 

test := RegExMatches("12_567", "\d(\d+)", 1) ; 取得子匹配 1 的结果
Msgbox test[1] "," test[2] ; --> 2,67 


RegExMatches(ByRef Haystack, NeedleRegEx, SubPat:=0)
{   
	 arr := [], startPos := 1   
	 while ( pos := RegExMatch(Haystack, NeedleRegEx, match, startPos) )
	  {  
	     arr.push(match[SubPat])    
	     startPos := pos + StrLen(match[SubPat]) 
	  }    
	 return arr.MaxIndex() ? arr : ""
}
Cheers.

Return to “Ask for Help”

Who is online

Users browsing this forum: No registered users and 18 guests