Help for grep and array Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
maitresin
Posts: 45
Joined: 20 Mar 2018, 19:33

Help for grep and array

20 Mar 2018, 19:50

Hello,

I want to do a grep and paste result into a .txt with both result from "g" and "g2" and so on. Please see below code and let me know what to enter in the "for i, v in g" section

Thanks!

Code: Select all

g:=grep(fileread2, "sU)id=""(.*)""")
g2:=grep(fileread2, "sU)No=""(.*)""")

countx := g.MaxIndex()
countx2 := g2.MaxIndex()

for i, v in g    ;Here I want to fileappend the first result found of "g" and "g2" and paste it into the "OrderID.txt". I know it is not good but it show what I want to do.
{
result1 := v.1
for i, w in g2
{
    result2 := w.1
}
fileappend, %result1% %result2% `n, OrderID.txt
}


grep(haystack, needle)
{
    a:=[], match := "", pos := 1
    while pos:=RegExMatch(haystack, needle, match, pos+StrLen(match))
        a[A_Index]:= {"match": match, 1: match1}
    Return a
}

maitresin
Posts: 45
Joined: 20 Mar 2018, 19:33

Re: Help fro grep and array

20 Mar 2018, 22:43

The following code work. However, I get every result in double! :( What is wrong?

Code: Select all

for i, v in g
{
result1 := v.1
gosub, secondgrep
fileappend, %result1% %result2% `n, OrderID.txt

}

secondgrep:
for i, w in g2
{
    result2 := w.1
}
continue
return
maitresin
Posts: 45
Joined: 20 Mar 2018, 19:33

Re: Help fro grep and array

21 Mar 2018, 16:57

Anyone able to help?

Thanks!
gregster
Posts: 8988
Joined: 30 Sep 2013, 06:48

Re: Help fro grep and array

21 Mar 2018, 17:13

Perhaps you should provide the input and the expected result. That could help others to help you.
maitresin
Posts: 45
Joined: 20 Mar 2018, 19:33

Re: Help fro grep and array

21 Mar 2018, 18:31

Exemple of Value in files: Id="11316832" No="90001267"

Expected Output in OrderId.txt : 11316832 90001267

Current Output in OrderId.txt: 11316832 90001267 ; it double the output :\
11316832 90001267

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bobak, jaka1, MrDoge and 235 guests