Simplify these RegEx !? Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
User avatar
V for Vendetta
Posts: 105
Joined: 29 Sep 2016, 11:33

Re: Simplify these RegEx !?

23 Nov 2016, 12:07

ozzii wrote: With your code I have all the lines beetween Look Down: and *****
But I need to have the result ONLY if there is just one line
if TotalResultFound > 1
{
ResultText = More than 1 Result found
break
}

Code: Select all

text=
(
line1
line2
line3
Look Down:
ResultLine
ResultLine2
ResultLine3
******************************************************************************
)

loop, parse, text, `n
{
	if A_LoopField = Look Down:
	{
	TextCreation = 1

	continue	;Skip lines below and start a new iteration and begins a new one
		;"a_index" count will be continued
	}

if A_LoopField = ******************************************************************************
TextCreation = 0

	if TextCreation = 1
	{
	ResultText .= A_LoopField "`r`n"
	TotalResultFound++

		if TotalResultFound > 1
		{
		ResultText = More than 1 Result found
		break
		}

	}
}

msgbox, %TotalResultFound% `n`n%ResultText%
ozzii
Posts: 370
Joined: 30 Oct 2013, 06:04

Re: Simplify these RegEx !?

23 Nov 2016, 12:16

@ahcahc
Thanks for ALL your answers.
I think I will stay with the loop because it's easier for me to read and understand :oops: :oops:
Also my file is usually around 60 lines. So the loop is quite fast.
And also I don't want to spend more of your time on this 'unnecessary' optimization

But I am really grateful for your help.
ozzii
Posts: 370
Joined: 30 Oct 2013, 06:04

Re: Simplify these RegEx !?

23 Nov 2016, 12:19

Thanks V, I will test this
ozzii
Posts: 370
Joined: 30 Oct 2013, 06:04

Re: Simplify these RegEx !?

23 Nov 2016, 12:31

@ahcahc
Forgot to say that your last command is working ;)

Return to “Ask For Help”

Who is online

Users browsing this forum: Google [Bot], hasantr, Reniazas, RubbeH, SimPlayer, wineguy, Zachk and 35 guests