Help to Extract Data

Get help with using AutoHotkey and its commands and hotkeys
Paddy9888
Posts: 7
Joined: 23 Aug 2019, 02:06

Help to Extract Data

07 Oct 2019, 02:59

I am trying to extract the values but not sure why to do using regexmatch.

Here is raw data:
Tracking Number:1Z9A6T164271256065 AY-06-101L ARYSE SM Left METFORCE ANKLE Ankle Brace L1906 1.00 Ea 0.32 Lb 0.32 Lb
Tracking Number:1Z9A6T164270579325 AY-37/50-104 ARYSE XL METFORCE BACK Back Brace L0650 1.00 Ea 1.11 Lb 1.11 Lb
Tracking Number:1Z9A6T164272115527 AY-3916 ARYSE Univ METFORCE WRIST Wrist Brace L3916 2.00 Ea 0.15 Lb 0.30 Lb
I need colored values split by tab
AY-06-101L `t ARYSE SM Left METFORCE ANKLE Ankle Brace `t L1906 `t 1.00
User avatar
TheDewd
Posts: 1391
Joined: 19 Dec 2013, 11:16
Location: USA

Re: Help to Extract Data

07 Oct 2019, 12:50

If the data always matches this specific pattern, this should work:

Code: Select all

#SingleInstance, Force

Data =
(LTRIM
	Tracking Number:1Z9A6T164271256065 AY-06-101L ARYSE SM Left METFORCE ANKLE Ankle Brace L1906 1.00 Ea 0.32 Lb 0.32 Lb
	Tracking Number:1Z9A6T164270579325 AY-37/50-104 ARYSE XL METFORCE BACK Back Brace L0650 1.00 Ea 1.11 Lb 1.11 Lb
	Tracking Number:1Z9A6T164272115527 AY-3916 ARYSE Univ METFORCE WRIST Wrist Brace L3916 2.00 Ea 0.15 Lb 0.30 Lb
)

FinalStr := ""

Pos := 0
While (Pos := RegExMatch(Data, ":.*?\s(.*?)\s(.*?)(L\d{4})\s(\d+.\d+)\s", Match, Pos + 1)) {
	FinalStr .= Match1 "`t" Match2 "`t" Match3 "`t" Match4 "`n"
}

MsgBox, % FinalStr

Code: Select all

AY-06-101L	ARYSE SM Left METFORCE ANKLE Ankle Brace 	L1906	1.00
AY-37/50-104	ARYSE XL METFORCE BACK Back Brace 	L0650	1.00
AY-3916	ARYSE Univ METFORCE WRIST Wrist Brace 	L3916	2.00
Image Bulldozer - Sokoban inspired game from 1994 recreated in AutoHotkey.
teadrinker
Posts: 1639
Joined: 29 Mar 2015, 09:41
Contact:

Re: Help to Extract Data

07 Oct 2019, 13:29

Code: Select all

text =
(
Tracking Number:1Z9A6T164271256065 AY-06-101L ARYSE SM Left METFORCE ANKLE Ankle Brace L1906 1.00 Ea 0.32 Lb 0.32 Lb
Tracking Number:1Z9A6T164270579325 AY-37/50-104 ARYSE XL METFORCE BACK Back Brace L0650 1.00 Ea 1.11 Lb 1.11 Lb
Tracking Number:1Z9A6T164272115527 AY-3916 ARYSE Univ METFORCE WRIST Wrist Brace L3916 2.00 Ea 0.15 Lb 0.30 Lb
)
MsgBox, % RegExReplace(text, "m`a)^\S+\s\S+\s(\S+)\s(.*)\s(L\d{4})\s(\S+).*?$", "$1" A_Tab "$2" A_Tab "$3" A_Tab "$4")
Paddy9888
Posts: 7
Joined: 23 Aug 2019, 02:06

Re: Help to Extract Data

08 Oct 2019, 07:28

Thanks but there are 2 more formats.
Tracking Number:1Z9A6T164270579325 AY-37/50-104 ARYSE XL METFORCE BACK Back Brace 00000 1.00 Ea 1.11 Lb 1.11 Lb
Tracking Number:1Z9A6T164272115527 AY-3916 ARYSE Univ METFORCE WRIST Wrist Brace 2.00 Ea 0.15 Lb 0.30 Lb
teadrinker
Posts: 1639
Joined: 29 Mar 2015, 09:41
Contact:

Re: Help to Extract Data

08 Oct 2019, 08:55

@Paddy9888
The last one doesn't match the pattern that you provided.

Return to “Ask For Help”

Who is online

Users browsing this forum: AHKStudent, Bing [Bot], Canengy, Google [Bot], KeoiMadBro, veasnaj26, Wigi, Xtra and 158 guests