question regex search help please

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
wannaknow

question regex search help please

16 Mar 2016, 09:55

i would like to know is it possible?

AAA = (123) (1234) (12345) (123456) (1234567) (54321)

i would like to search useing regex only

inside of parenthesis the sum is 5

please help... :cry:
Paneb
Posts: 54
Joined: 24 Aug 2015, 05:02
Location: France
Contact:

Re: question regex search help please

16 Mar 2016, 10:40

When you say if the sum is 5, do you mean you want to have a result when there is only five number? Like this:

Code: Select all

#Persistent

AAA := "(123) (1234) (12345) (123456) (1234567) (54321)"
pos := 0
indice := 0
foundItems := Object()
element :=
While, pos := RegExMatch(AAA, "\(.*?\)", entree, pos + 1)
{
	taille := StrLen(entree)
	If(taille == 7){
		indice += 1
		foundItems[ indice ] := entree
	}
}

Loop %indice%
{
	MsgBox, % foundItems[A_Index]
}

User avatar
sinkfaze
Posts: 616
Joined: 01 Oct 2013, 08:01

Re: question regex search help please

16 Mar 2016, 15:06

I agree with Paneb, the goal here is kind of vague, particularly since what you appear to want doesn't even show up in your example:

Code: Select all

AAA=(123) (1234) (12345) (123456) (1234567) (54321)
Pos=1
While	Pos :=	RegExMatch(AAA,"\(\K\d+(?=\))",m,Pos+StrLen(m))
{
	sum :=	0
	Loop, parse, m
		sum +=	A_LoopField
	MsgBox, The sum is %sum%.
}
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: CrowexBR, mebelantikjaya and 306 guests