Condition that a "WORD" is inside a Matched "algorithm" on RegExMatch Operation Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
aldrinjohnom
Posts: 77
Joined: 18 Apr 2018, 08:49

Condition that a "WORD" is inside a Matched "algorithm" on RegExMatch Operation

23 Jul 2018, 11:09

Hello, I just started studying about Regular Expressions 3 days ago. This Regular Expression can give a very big help when searching strings with specific boundaries,ect. I am trying to Find a thing I called "Section" on a text file that I called "Database":

This is the Database:

Code: Select all

		"5654"
		{
			"name"		"NaN"
			"outline"		"frost"
			{....sometext}
		}
		"5655"
		{
			"prefab"	"destroyer"
			"summon"	"analyzer"
			{....sometext}
		}
		"5656"
		{
			"name"	"foul"
			"dream"	"BSECE"
			{....sometext}
		}
		"5657"
		{
			"name"	"solar"
			"function"	"fire"
			{....sometext}
		}
		"5656"
		{
			"name"	"sean"
			"prefab"	"emerald dream"
			"dream"	"BSECE"
			{....sometext}
		}
		"5657"
		{
			"name"	"brandon"
			"course"	"BSECE"
			{....sometext}
		}


and the "Section" I want my RegExMatch to find is the one that has an "ID" of 5656 and inside this section, a word "prefab" should exist.... The Result of the RegExMatch should be:

Code: Select all

		}
		"5656"
		{
			"name"	"sean"
			"prefab"	"emerald dream"
			"dream"	"BSECE"
			{....sometext}
		}

( "prefab" "emerald dream" ) ;;;; <<<<-------- it has a prefab therefore this section is the one that will be the result....



My first Try of RegExMatch():

Code: Select all

;;; Haystack is the Database
Haystack=
(
		"5654"
		{
			"name"		"NaN"
			"outline"		"frost"
			{....sometext}
		}
		"5655"
		{
			"prefab"	"destroyer"
			"summon"	"analyzer"
			{....sometext}
		}
		"5656"
		{
			"name"	"foul"
			"dream"	"BSECE"
			{....sometext}
		}
		"5657"
		{
			"name"	"solar"
			"function"	"fire"
			{....sometext}
		}
		"5656"
		{
			"name"	"sean"
			"prefab"	"emerald dream"
			"dream"	"BSECE"
			{....sometext}
		}
		"5657"
		{
			"name"	"brandon"
			"course"	"BSECE"
			{....sometext}
		}
)


/*
This RegExMatch will search for section "5656" with certain pattern, then after fiding the match, it will inspect whether the matched has a word "prefab" inside it.
What the RegExMatch was trying to do is:
1) Find this string:
"		}
		"5657"
		{ "

2) Greed forward to the right,consuming all characters until encountering this string:
"
		} "

3) Do a "Conditional Statement". If the "currently Matched" RegEx has a word "prefab", then stop searching and PUT IT in variable "found"... Else continue finding another match.
*/
RegExMatch(Haystack2, "i s)		}\R		""5656""\R		{.*?(\R		})(?=.*?""prefab"")",found)
but this code return the "first 5656" section. which this section has no "prefab" inside it. I think I have problem with my RegExMatch



Can somebody Fix my RegExMatch?

I currently limit my Script Operations, So Ideas like this is Irrelevant for me because It consume Speed A Lot:

Code: Select all

loop
{
	RegExMatch(Haystack2, "i s)		}\R		""5656""\R		{.*?\R		}",found)
	if instr(found,"""prefab""") or (ErrorLevel=1)
	{
		break
	}
}

That is why I limit myself into "One RegExMatch".


Cheers to the Awesome Community!!! :rainbow:
Developer of AJOM's DOTA2 MOD Master, Easiest way to MOD your DOTA2 without the use of internet :lol: . I created this program using Autohotkey thats why I love Autohotkey and the community!

GitHub:
https://github.com/Aldrin-John-Olaer-Manalansan
awel20
Posts: 211
Joined: 19 Mar 2018, 14:09

Re: Condition that a "WORD" is inside a Matched "algorithm" on RegExMatch Operation

23 Jul 2018, 12:55

Code: Select all

Haystack = 
(Join`r`n
		"5654"
		{
			"name"		"NaN"
			"outline"		"frost"
			{....sometext}
		}
		"5655"
		{
			"prefab"	"destroyer"
			"summon"	"analyzer"
			{....sometext}
		}
		"5656"
		{
			"name"	"foul"
			"dream"	"BSECE"
			{....sometext}
		}
		"5657"
		{
			"name"	"solar"
			"function"	"fire"
			{....sometext}
		}
		"5656"
		{
			"name"	"sean"
			"prefab"	"emerald dream"
			"dream"	"BSECE"
			{....sometext}
		}
		"5657"
		{
			"name"	"brandon"
			"course"	"BSECE"
			{....sometext}
		}

)

RegExMatch(Haystack, "`a)(^|\R)\K\s*""5656""\R\s*\{[^{}]*""prefab""[^{}]*\{[^{}]*\}\R\s*\}", UnquotedOutputVar)
MsgBox % UnquotedOutputVar
ExitApp
aldrinjohnom
Posts: 77
Joined: 18 Apr 2018, 08:49

Re: Condition that a "WORD" is inside a Matched "algorithm" on RegExMatch Operation

23 Jul 2018, 17:19

awel20 wrote:

Code: Select all

Haystack = 
(Join`r`n
		"5654"
		{
			"name"		"NaN"
			"outline"		"frost"
			{....sometext}
		}
		"5655"
		{
			"prefab"	"destroyer"
			"summon"	"analyzer"
			{....sometext}
		}
		"5656"
		{
			"name"	"foul"
			"dream"	"BSECE"
			{....sometext}
		}
		"5657"
		{
			"name"	"solar"
			"function"	"fire"
			{....sometext}
		}
		"5656"
		{
			"name"	"sean"
			"prefab"	"emerald dream"
			"dream"	"BSECE"
			{....sometext}
		}
		"5657"
		{
			"name"	"brandon"
			"course"	"BSECE"
			{....sometext}
		}

)

RegExMatch(Haystack, "`a)(^|\R)\K\s*""5656""\R\s*\{[^{}]*""prefab""[^{}]*\{[^{}]*\}\R\s*\}", UnquotedOutputVar)
MsgBox % UnquotedOutputVar
ExitApp
That was Awesome! But I got a question, and a problem.

Question:
Can you please explain each step by step How you created that RegExMatch? I mean how it was constructed? Comparing it to my regexmatch code, that code is obfuscated for me. Im sorry, I'm very noob at RegEx and needs to gain knowledge from experienced.


Problem:
It worked on my example Database, and that was impressive, but why does it not work on this database?

Code: Select all

Haystack = 
(Join`r`n
		}
		"5654"
		{
			"name"		"Belt of the Gleaming Seal"
			"prefab"		"wearable"
			"creation_date"		"2013-11-06"
			"image_inventory"		"econ/items/phantom_assassin/lodas_pa_set__belt/lodas_pa_set__belt"
			"item_description"		"#DOTA_Item_Desc_Belt_of_the_Gleaming_Seal"
			"item_name"		"#DOTA_Item_Belt_of_the_Gleaming_Seal"
			"item_slot"		"belt"
			"item_type_name"		"#DOTA_WearableType_Honored_Belt"
			"model_player"		"models/items/phantom_assassin/lodas_pa_set__belt/lodas_pa_set__belt.vmdl"
			"portraits"
			{
				"icon"
				{
					"PortraitLightPosition"		"76.932938 -29.410818 221.487381"
					"PortraitLightAngles"		"57.661743 141.822510 0.000000"
					"PortraitLightFOV"		"46.000000"
					"PortraitLightDistance"		"242.000000"
					"PortraitLightColor"		"254 254 254"
					"PortraitShadowColor"		"97 97 97"
					"PortraitShadowScale"		"1.500000"
					"PortraitGroundShadowScale"		"1.500000"
					"PortraitAmbientColor"		"148 148 148"
					"PortraitAmbientScale"		"2.750000"
					"PortraitSpecularColor"		"251 74 84"
					"PortraitSpecularDirection"		"0.000000 0.000000 -1.000000"
					"PortraitSpecularPower"		"16.000000"
					"PortraitBackgroundColor1"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor2"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor3"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor4"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundTexture"		"materials/vgui/econ/item_icon_bg.vmat"
					"PortraitAnimationActivity"		"ACT_DOTA_CAPTURE"
					"PortraitAnimationCycle"		"0.000000"
					"PortraitAnimationRate"		"0.000000"
					"PortraitHideHero"		"0"
					"PortraitLightScale"		"1.750000"
					"PortraitAmbientDirection"		"197.904 4.526 -33.190"
					"cameras"
					{
						"default"
						{
							"PortraitPosition"		"182.981750 -85.518150 126.108841"
							"PortraitAngles"		"8.997803 154.621582 2.109375"
							"PortraitFOV"		"22.000000"
							"PortraitFar"		"1000.000000"
						}
					}
				}
			}
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"used_by_heroes"
			{
				"npc_dota_hero_phantom_assassin"		"1"
			}
			"branding"
			{
				"team_id"		"111474"
			}
		}
		"5655"
		{
			"name"		"Cape of the Gleaming Seal"
			"prefab"		"wearable"
			"creation_date"		"2013-11-06"
			"image_inventory"		"econ/items/phantom_assassin/lodas_pa_set__cape/lodas_pa_set__cape"
			"item_description"		"#DOTA_Item_Desc_Cape_of_the_Gleaming_Seal"
			"item_name"		"#DOTA_Item_Cape_of_the_Gleaming_Seal"
			"item_slot"		"back"
			"item_type_name"		"#DOTA_WearableType_Honored_Cape"
			"model_player"		"models/items/phantom_assassin/lodas_pa_set__cape/lodas_pa_set__cape.vmdl"
			"portraits"
			{
				"icon"
				{
					"PortraitLightPosition"		"-104.916451 137.334091 203.602936"
					"PortraitLightAngles"		"43.143311 298.712769 0.000000"
					"PortraitLightFOV"		"46.000000"
					"PortraitLightDistance"		"242.000000"
					"PortraitLightColor"		"254 254 254"
					"PortraitShadowColor"		"97 97 97"
					"PortraitShadowScale"		"1.500000"
					"PortraitGroundShadowScale"		"1.500000"
					"PortraitAmbientColor"		"148 148 148"
					"PortraitAmbientScale"		"2.750000"
					"PortraitSpecularColor"		"251 74 84"
					"PortraitSpecularDirection"		"0.000000 0.000000 -1.000000"
					"PortraitSpecularPower"		"16.000000"
					"PortraitBackgroundColor1"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor2"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor3"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor4"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundTexture"		"materials/vgui/econ/item_icon_bg.vmat"
					"PortraitAnimationActivity"		"ACT_DOTA_CAPTURE"
					"PortraitAnimationCycle"		"0.272000"
					"PortraitAnimationRate"		"0.000000"
					"PortraitHideHero"		"0"
					"PortraitLightScale"		"1.750000"
					"PortraitAmbientDirection"		"197.904 4.526 -33.190"
					"cameras"
					{
						"default"
						{
							"PortraitPosition"		"-295.851105 165.136505 186.125473"
							"PortraitAngles"		"20.522461 331.534424 2.109375"
							"PortraitFOV"		"37.000000"
							"PortraitFar"		"1000.000000"
						}
					}
				}
			}
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"used_by_heroes"
			{
				"npc_dota_hero_phantom_assassin"		"1"
			}
			"branding"
			{
				"team_id"		"111474"
			}
		}
		"5656"
		{
			"name"		"Brooch of the Gleaming Seal"
			"prefab"		"wearable"
			"creation_date"		"2013-11-06"
			"image_inventory"		"econ/items/phantom_assassin/lodas_pa_set__head/lodas_pa_set__head"
			"item_description"		"#DOTA_Item_Desc_Brooch_of_the_Gleaming_Seal"
			"item_name"		"#DOTA_Item_Brooch_of_the_Gleaming_Seal"
			"item_rarity"		"uncommon"
			"item_slot"		"head"
			"item_type_name"		"#DOTA_WearableType_Honored_Brooch"
			"model_player"		"models/items/phantom_assassin/lodas_pa_set__head/lodas_pa_set__head.vmdl"
			"portraits"
			{
				"icon"
				{
					"PortraitLightPosition"		"76.932938 -29.410818 221.487381"
					"PortraitLightAngles"		"38.671875 155.000610 0.000000"
					"PortraitLightFOV"		"34.000000"
					"PortraitLightDistance"		"130.000000"
					"PortraitLightColor"		"254 254 254"
					"PortraitShadowColor"		"97 97 97"
					"PortraitShadowScale"		"1.500000"
					"PortraitGroundShadowScale"		"1.500000"
					"PortraitAmbientColor"		"148 148 148"
					"PortraitAmbientScale"		"2.750000"
					"PortraitSpecularColor"		"251 74 84"
					"PortraitSpecularDirection"		"0.000000 0.000000 -1.000000"
					"PortraitSpecularPower"		"16.000000"
					"PortraitBackgroundColor1"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor2"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor3"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor4"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundTexture"		"materials/vgui/econ/item_icon_bg.vmat"
					"PortraitAnimationActivity"		"ACT_DOTA_CAPTURE"
					"PortraitAnimationCycle"		"0.000000"
					"PortraitAnimationRate"		"0.000000"
					"PortraitHideHero"		"0"
					"PortraitLightScale"		"1.750000"
					"PortraitAmbientDirection"		"197.904 4.526 -33.190"
					"cameras"
					{
						"default"
						{
							"PortraitPosition"		"187.467773 -76.296227 122.148560"
							"PortraitAngles"		"351.513062 155.308228 2.109375"
							"PortraitFOV"		"23.000000"
							"PortraitFar"		"1000.000000"
						}
					}
				}
			}
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"used_by_heroes"
			{
				"npc_dota_hero_phantom_assassin"		"1"
			}
			"branding"
			{
				"team_id"		"111474"
			}
		}
		"5657"
		{
			"name"		"Ornaments of the Gleaming Seal"
			"prefab"		"wearable"
			"creation_date"		"2013-11-06"
			"image_inventory"		"econ/items/phantom_assassin/lodas_pa_set__shoulders/lodas_pa_set__shoulders"
			"item_description"		"#DOTA_Item_Desc_Ornaments_of_the_Gleaming_Seal"
			"item_name"		"#DOTA_Item_Ornaments_of_the_Gleaming_Seal"
			"item_rarity"		"rare"
			"item_slot"		"shoulder"
			"item_type_name"		"#DOTA_WearableType_Honored_Shoulders"
			"model_player"		"models/items/phantom_assassin/lodas_pa_set__shoulders/lodas_pa_set__shoulders.vmdl"
			"portraits"
			{
				"icon"
				{
					"PortraitLightPosition"		"76.932938 -29.410818 221.487381"
					"PortraitLightAngles"		"57.661743 141.822510 0.000000"
					"PortraitLightFOV"		"46.000000"
					"PortraitLightDistance"		"242.000000"
					"PortraitLightColor"		"254 254 254"
					"PortraitShadowColor"		"97 97 97"
					"PortraitShadowScale"		"1.500000"
					"PortraitGroundShadowScale"		"1.500000"
					"PortraitAmbientColor"		"148 148 148"
					"PortraitAmbientScale"		"2.750000"
					"PortraitSpecularColor"		"251 74 84"
					"PortraitSpecularDirection"		"0.000000 0.000000 -1.000000"
					"PortraitSpecularPower"		"16.000000"
					"PortraitBackgroundColor1"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor2"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor3"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor4"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundTexture"		"materials/vgui/econ/item_icon_bg.vmat"
					"PortraitAnimationActivity"		"ACT_DOTA_CAPTURE"
					"PortraitAnimationCycle"		"0.000000"
					"PortraitAnimationRate"		"0.000000"
					"PortraitHideHero"		"0"
					"PortraitLightScale"		"1.750000"
					"PortraitAmbientDirection"		"197.904 4.526 -33.190"
					"cameras"
					{
						"default"
						{
							"PortraitPosition"		"187.467773 -76.296227 122.148560"
							"PortraitAngles"		"357.363281 155.198364 2.109375"
							"PortraitFOV"		"24.000000"
							"PortraitFar"		"1000.000000"
						}
					}
				}
			}
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"used_by_heroes"
			{
				"npc_dota_hero_phantom_assassin"		"1"
			}
			"branding"
			{
				"team_id"		"111474"
			}
		}
)


RegExMatch(Haystack, "i s `a)(^|\R)\K\s*""5656""\R\s*\{[^{}]*""prefab""[^{}]*\{[^{}]*\}\R\s*\}", UnquotedOutputVar)
MsgBox % UnquotedOutputVar
I think the RegExMatch should do is:
1)search for this word "%A_Tab%%A_Tab%}`r`n%A_Tab%%A_Tab%"5656"`r`n%A_Tab%%A_Tab%{"
2)consume anything after that word until encountering this word "`r`n%A_Tab%%A_Tab%}"
3)if the matched case has a word "prefab" then stop searching and put to variable. else find another match



Many thanks!!!
Developer of AJOM's DOTA2 MOD Master, Easiest way to MOD your DOTA2 without the use of internet :lol: . I created this program using Autohotkey thats why I love Autohotkey and the community!

GitHub:
https://github.com/Aldrin-John-Olaer-Manalansan
aldrinjohnom
Posts: 77
Joined: 18 Apr 2018, 08:49

Re: Condition that a "WORD" is inside a Matched "algorithm" on RegExMatch Operation

23 Jul 2018, 21:36

Ok, so I currently am making a progress right now. I can now extract the contents of my desired section with "prefab":

Code: Select all

Haystack2=
(
		"5654"
		{
			"name"		"Belt of the Gleaming Seal"
			"prefab"		"wearable"
			"creation_date"		"2013-11-06"
			"image_inventory"		"econ/items/phantom_assassin/lodas_pa_set__belt/lodas_pa_set__belt"
			"item_description"		"#DOTA_Item_Desc_Belt_of_the_Gleaming_Seal"
			"item_name"		"#DOTA_Item_Belt_of_the_Gleaming_Seal"
			"item_slot"		"belt"
			"item_type_name"		"#DOTA_WearableType_Honored_Belt"
			"model_player"		"models/items/phantom_assassin/lodas_pa_set__belt/lodas_pa_set__belt.vmdl"
			"portraits"
			{
				"icon"
				{
					"PortraitLightPosition"		"76.932938 -29.410818 221.487381"
					"PortraitLightAngles"		"57.661743 141.822510 0.000000"
					"PortraitLightFOV"		"46.000000"
					"PortraitLightDistance"		"242.000000"
					"PortraitLightColor"		"254 254 254"
					"PortraitShadowColor"		"97 97 97"
					"PortraitShadowScale"		"1.500000"
					"PortraitGroundShadowScale"		"1.500000"
					"PortraitAmbientColor"		"148 148 148"
					"PortraitAmbientScale"		"2.750000"
					"PortraitSpecularColor"		"251 74 84"
					"PortraitSpecularDirection"		"0.000000 0.000000 -1.000000"
					"PortraitSpecularPower"		"16.000000"
					"PortraitBackgroundColor1"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor2"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor3"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor4"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundTexture"		"materials/vgui/econ/item_icon_bg.vmat"
					"PortraitAnimationActivity"		"ACT_DOTA_CAPTURE"
					"PortraitAnimationCycle"		"0.000000"
					"PortraitAnimationRate"		"0.000000"
					"PortraitHideHero"		"0"
					"PortraitLightScale"		"1.750000"
					"PortraitAmbientDirection"		"197.904 4.526 -33.190"
					"cameras"
					{
						"default"
						{
							"PortraitPosition"		"182.981750 -85.518150 126.108841"
							"PortraitAngles"		"8.997803 154.621582 2.109375"
							"PortraitFOV"		"22.000000"
							"PortraitFar"		"1000.000000"
						}
					}
				}
			}
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"used_by_heroes"
			{
				"npc_dota_hero_phantom_assassin"		"1"
			}
			"branding"
			{
				"team_id"		"111474"
			}
		}
		"5655"
		{
			"name"		"Cape of the Gleaming Seal"
			"prefab"		"wearable"
			"creation_date"		"2013-11-06"
			"image_inventory"		"econ/items/phantom_assassin/lodas_pa_set__cape/lodas_pa_set__cape"
			"item_description"		"#DOTA_Item_Desc_Cape_of_the_Gleaming_Seal"
			"item_name"		"#DOTA_Item_Cape_of_the_Gleaming_Seal"
			"item_slot"		"back"
			"item_type_name"		"#DOTA_WearableType_Honored_Cape"
			"model_player"		"models/items/phantom_assassin/lodas_pa_set__cape/lodas_pa_set__cape.vmdl"
			"portraits"
			{
				"icon"
				{
					"PortraitLightPosition"		"-104.916451 137.334091 203.602936"
					"PortraitLightAngles"		"43.143311 298.712769 0.000000"
					"PortraitLightFOV"		"46.000000"
					"PortraitLightDistance"		"242.000000"
					"PortraitLightColor"		"254 254 254"
					"PortraitShadowColor"		"97 97 97"
					"PortraitShadowScale"		"1.500000"
					"PortraitGroundShadowScale"		"1.500000"
					"PortraitAmbientColor"		"148 148 148"
					"PortraitAmbientScale"		"2.750000"
					"PortraitSpecularColor"		"251 74 84"
					"PortraitSpecularDirection"		"0.000000 0.000000 -1.000000"
					"PortraitSpecularPower"		"16.000000"
					"PortraitBackgroundColor1"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor2"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor3"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor4"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundTexture"		"materials/vgui/econ/item_icon_bg.vmat"
					"PortraitAnimationActivity"		"ACT_DOTA_CAPTURE"
					"PortraitAnimationCycle"		"0.272000"
					"PortraitAnimationRate"		"0.000000"
					"PortraitHideHero"		"0"
					"PortraitLightScale"		"1.750000"
					"PortraitAmbientDirection"		"197.904 4.526 -33.190"
					"cameras"
					{
						"default"
						{
							"PortraitPosition"		"-295.851105 165.136505 186.125473"
							"PortraitAngles"		"20.522461 331.534424 2.109375"
							"PortraitFOV"		"37.000000"
							"PortraitFar"		"1000.000000"
						}
					}
				}
			}
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"used_by_heroes"
			{
				"npc_dota_hero_phantom_assassin"		"1"
			}
			"branding"
			{
				"team_id"		"111474"
			}
		}
		"5656"
		{
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"used_by_heroes"
			{
				"npc_dota_hero_phantom_assassin"		"1"
			}
			"branding"
			{
				"team_id"		"111474"
			}
		}
		"5657"
		{
			"name"		"Ornaments of the Gleaming Seal"
			"prefab"		"wearable"
			"creation_date"		"2013-11-06"
			"image_inventory"		"econ/items/phantom_assassin/lodas_pa_set__shoulders/lodas_pa_set__shoulders"
			"item_description"		"#DOTA_Item_Desc_Ornaments_of_the_Gleaming_Seal"
			"item_name"		"#DOTA_Item_Ornaments_of_the_Gleaming_Seal"
			"item_rarity"		"rare"
			"item_slot"		"shoulder"
			"item_type_name"		"#DOTA_WearableType_Honored_Shoulders"
			"model_player"		"models/items/phantom_assassin/lodas_pa_set__shoulders/lodas_pa_set__shoulders.vmdl"
			"portraits"
			{
				"icon"
				{
					"PortraitLightPosition"		"76.932938 -29.410818 221.487381"
					"PortraitLightAngles"		"57.661743 141.822510 0.000000"
					"PortraitLightFOV"		"46.000000"
					"PortraitLightDistance"		"242.000000"
					"PortraitLightColor"		"254 254 254"
					"PortraitShadowColor"		"97 97 97"
					"PortraitShadowScale"		"1.500000"
					"PortraitGroundShadowScale"		"1.500000"
					"PortraitAmbientColor"		"148 148 148"
					"PortraitAmbientScale"		"2.750000"
					"PortraitSpecularColor"		"251 74 84"
					"PortraitSpecularDirection"		"0.000000 0.000000 -1.000000"
					"PortraitSpecularPower"		"16.000000"
					"PortraitBackgroundColor1"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor2"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor3"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor4"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundTexture"		"materials/vgui/econ/item_icon_bg.vmat"
					"PortraitAnimationActivity"		"ACT_DOTA_CAPTURE"
					"PortraitAnimationCycle"		"0.000000"
					"PortraitAnimationRate"		"0.000000"
					"PortraitHideHero"		"0"
					"PortraitLightScale"		"1.750000"
					"PortraitAmbientDirection"		"197.904 4.526 -33.190"
					"cameras"
					{
						"default"
						{
							"PortraitPosition"		"187.467773 -76.296227 122.148560"
							"PortraitAngles"		"357.363281 155.198364 2.109375"
							"PortraitFOV"		"24.000000"
							"PortraitFar"		"1000.000000"
						}
					}
				}
			}
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"used_by_heroes"
			{
				"npc_dota_hero_phantom_assassin"		"1"
			}
			"branding"
			{
				"team_id"		"111474"
			}
		}
		"5656"
		{
			"name"		"Brooch of the Gleaming Seal"
			"prefab"		"wearable"
			"creation_date"		"2013-11-06"
			"image_inventory"		"econ/items/phantom_assassin/lodas_pa_set__head/lodas_pa_set__head"
			"item_description"		"#DOTA_Item_Desc_Brooch_of_the_Gleaming_Seal"
			"item_name"		"#DOTA_Item_Brooch_of_the_Gleaming_Seal"
			"item_rarity"		"uncommon"
			"item_slot"		"head"
			"item_type_name"		"#DOTA_WearableType_Honored_Brooch"
			"model_player"		"models/items/phantom_assassin/lodas_pa_set__head/lodas_pa_set__head.vmdl"
			"portraits"
			{
				"icon"
				{
					"PortraitLightPosition"		"76.932938 -29.410818 221.487381"
					"PortraitLightAngles"		"38.671875 155.000610 0.000000"
					"PortraitLightFOV"		"34.000000"
					"PortraitLightDistance"		"130.000000"
					"PortraitLightColor"		"254 254 254"
					"PortraitShadowColor"		"97 97 97"
					"PortraitShadowScale"		"1.500000"
					"PortraitGroundShadowScale"		"1.500000"
					"PortraitAmbientColor"		"148 148 148"
					"PortraitAmbientScale"		"2.750000"
					"PortraitSpecularColor"		"251 74 84"
					"PortraitSpecularDirection"		"0.000000 0.000000 -1.000000"
					"PortraitSpecularPower"		"16.000000"
					"PortraitBackgroundColor1"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor2"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor3"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor4"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundTexture"		"materials/vgui/econ/item_icon_bg.vmat"
					"PortraitAnimationActivity"		"ACT_DOTA_CAPTURE"
					"PortraitAnimationCycle"		"0.000000"
					"PortraitAnimationRate"		"0.000000"
					"PortraitHideHero"		"0"
					"PortraitLightScale"		"1.750000"
					"PortraitAmbientDirection"		"197.904 4.526 -33.190"
					"cameras"
					{
						"default"
						{
							"PortraitPosition"		"187.467773 -76.296227 122.148560"
							"PortraitAngles"		"351.513062 155.308228 2.109375"
							"PortraitFOV"		"23.000000"
							"PortraitFar"		"1000.000000"
						}
					}
				}
			}
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"branding"
			{
				"team_id"		"111474"
			}
		}
		"5657"
		{
			"name"		"Ornaments of the Gleaming Seal"
			"prefab"		"wearable"
			"creation_date"		"2013-11-06"
			"image_inventory"		"econ/items/phantom_assassin/lodas_pa_set__shoulders/lodas_pa_set__shoulders"
			"item_description"		"#DOTA_Item_Desc_Ornaments_of_the_Gleaming_Seal"
			"item_name"		"#DOTA_Item_Ornaments_of_the_Gleaming_Seal"
			"item_rarity"		"rare"
			"item_slot"		"shoulder"
			"item_type_name"		"#DOTA_WearableType_Honored_Shoulders"
			"model_player"		"models/items/phantom_assassin/lodas_pa_set__shoulders/lodas_pa_set__shoulders.vmdl"
			"portraits"
			{
				"icon"
				{
					"PortraitLightPosition"		"76.932938 -29.410818 221.487381"
					"PortraitLightAngles"		"57.661743 141.822510 0.000000"
					"PortraitLightFOV"		"46.000000"
					"PortraitLightDistance"		"242.000000"
					"PortraitLightColor"		"254 254 254"
					"PortraitShadowColor"		"97 97 97"
					"PortraitShadowScale"		"1.500000"
					"PortraitGroundShadowScale"		"1.500000"
					"PortraitAmbientColor"		"148 148 148"
					"PortraitAmbientScale"		"2.750000"
					"PortraitSpecularColor"		"251 74 84"
					"PortraitSpecularDirection"		"0.000000 0.000000 -1.000000"
					"PortraitSpecularPower"		"16.000000"
					"PortraitBackgroundColor1"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor2"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor3"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor4"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundTexture"		"materials/vgui/econ/item_icon_bg.vmat"
					"PortraitAnimationActivity"		"ACT_DOTA_CAPTURE"
					"PortraitAnimationCycle"		"0.000000"
					"PortraitAnimationRate"		"0.000000"
					"PortraitHideHero"		"0"
					"PortraitLightScale"		"1.750000"
					"PortraitAmbientDirection"		"197.904 4.526 -33.190"
					"cameras"
					{
						"default"
						{
							"PortraitPosition"		"187.467773 -76.296227 122.148560"
							"PortraitAngles"		"357.363281 155.198364 2.109375"
							"PortraitFOV"		"24.000000"
							"PortraitFar"		"1000.000000"
						}
					}
				}
			}
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"used_by_heroes"
			{
				"npc_dota_hero_phantom_assassin"		"1"
			}
			"branding"
			{
				"team_id"		"111474"
			}
		}
		"5656"
		{
			"name"		"Brooch of the Gleaming Seal"
			"prefab"		"wearable"
			"creation_date"		"2013-11-06"
			"image_inventory"		"econ/items/phantom_assassin/lodas_pa_set__head/lodas_pa_set__head"
			"item_description"		"#DOTA_Item_Desc_Brooch_of_the_Gleaming_Seal"
			"item_name"		"#DOTA_Item_Brooch_of_the_Gleaming_Seal"
			"item_rarity"		"uncommon"
			"item_slot"		"head"
			"item_type_name"		"#DOTA_WearableType_Honored_Brooch"
			"model_player"		"models/items/phantom_assassin/lodas_pa_set__head/lodas_pa_set__head.vmdl"
			"portraits"
			{
				"icon"
				{
					"PortraitLightPosition"		"76.932938 -29.410818 221.487381"
					"PortraitLightAngles"		"38.671875 155.000610 0.000000"
					"PortraitLightFOV"		"34.000000"
					"PortraitLightDistance"		"130.000000"
					"PortraitLightColor"		"254 254 254"
					"PortraitShadowColor"		"97 97 97"
					"PortraitShadowScale"		"1.500000"
					"PortraitGroundShadowScale"		"1.500000"
					"PortraitAmbientColor"		"148 148 148"
					"PortraitAmbientScale"		"2.750000"
					"PortraitSpecularColor"		"251 74 84"
					"PortraitSpecularDirection"		"0.000000 0.000000 -1.000000"
					"PortraitSpecularPower"		"16.000000"
					"PortraitBackgroundColor1"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor2"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor3"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor4"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundTexture"		"materials/vgui/econ/item_icon_bg.vmat"
					"PortraitAnimationActivity"		"ACT_DOTA_CAPTURE"
					"PortraitAnimationCycle"		"0.000000"
					"PortraitAnimationRate"		"0.000000"
					"PortraitHideHero"		"0"
					"PortraitLightScale"		"1.750000"
					"PortraitAmbientDirection"		"197.904 4.526 -33.190"
					"cameras"
					{
						"default"
						{
							"PortraitPosition"		"187.467773 -76.296227 122.148560"
							"PortraitAngles"		"351.513062 155.308228 2.109375"
							"PortraitFOV"		"23.000000"
							"PortraitFar"		"1000.000000"
						}
					}
				}
			}
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"used_by_heroes"
			{
				"npc_dota_hero_phantom_assassin"		"1"
			}
			"branding"
			{
				"team_id"		"111474"
			}
		}

)
RegExMatch(Haystack2,"i s)\t\t\}\R\t\t""5656""\R\t\t\{*[^{}]*""prefab""[^{}].*?\R\t\t\}",found)
MsgBox % found

Now I have a question and another case:


Question:

what does " {*[^{}] " mean? I can't understand what this do to know if the matched content has "prefab".




Case:

Suppose that using

Code: Select all

RegExMatch(Haystack2,"i s)\t\t\}\R\t\t""5656""\R\t\t\{*[^{}]*""prefab""[^{}].*?\R\t\t\}",found)
variable "found" will extract section "5656" with a word "prefab" inside its content.


But how about "5656" with a word "prefab" AND "used_by_heroes" inside its content? this code does not work:

Code: Select all

Haystack2=
(
		"5654"
		{
			"name"		"Belt of the Gleaming Seal"
			"prefab"		"wearable"
			"creation_date"		"2013-11-06"
			"image_inventory"		"econ/items/phantom_assassin/lodas_pa_set__belt/lodas_pa_set__belt"
			"item_description"		"#DOTA_Item_Desc_Belt_of_the_Gleaming_Seal"
			"item_name"		"#DOTA_Item_Belt_of_the_Gleaming_Seal"
			"item_slot"		"belt"
			"item_type_name"		"#DOTA_WearableType_Honored_Belt"
			"model_player"		"models/items/phantom_assassin/lodas_pa_set__belt/lodas_pa_set__belt.vmdl"
			"portraits"
			{
				"icon"
				{
					"PortraitLightPosition"		"76.932938 -29.410818 221.487381"
					"PortraitLightAngles"		"57.661743 141.822510 0.000000"
					"PortraitLightFOV"		"46.000000"
					"PortraitLightDistance"		"242.000000"
					"PortraitLightColor"		"254 254 254"
					"PortraitShadowColor"		"97 97 97"
					"PortraitShadowScale"		"1.500000"
					"PortraitGroundShadowScale"		"1.500000"
					"PortraitAmbientColor"		"148 148 148"
					"PortraitAmbientScale"		"2.750000"
					"PortraitSpecularColor"		"251 74 84"
					"PortraitSpecularDirection"		"0.000000 0.000000 -1.000000"
					"PortraitSpecularPower"		"16.000000"
					"PortraitBackgroundColor1"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor2"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor3"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor4"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundTexture"		"materials/vgui/econ/item_icon_bg.vmat"
					"PortraitAnimationActivity"		"ACT_DOTA_CAPTURE"
					"PortraitAnimationCycle"		"0.000000"
					"PortraitAnimationRate"		"0.000000"
					"PortraitHideHero"		"0"
					"PortraitLightScale"		"1.750000"
					"PortraitAmbientDirection"		"197.904 4.526 -33.190"
					"cameras"
					{
						"default"
						{
							"PortraitPosition"		"182.981750 -85.518150 126.108841"
							"PortraitAngles"		"8.997803 154.621582 2.109375"
							"PortraitFOV"		"22.000000"
							"PortraitFar"		"1000.000000"
						}
					}
				}
			}
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"used_by_heroes"
			{
				"npc_dota_hero_phantom_assassin"		"1"
			}
			"branding"
			{
				"team_id"		"111474"
			}
		}
		"5655"
		{
			"name"		"Cape of the Gleaming Seal"
			"prefab"		"wearable"
			"creation_date"		"2013-11-06"
			"image_inventory"		"econ/items/phantom_assassin/lodas_pa_set__cape/lodas_pa_set__cape"
			"item_description"		"#DOTA_Item_Desc_Cape_of_the_Gleaming_Seal"
			"item_name"		"#DOTA_Item_Cape_of_the_Gleaming_Seal"
			"item_slot"		"back"
			"item_type_name"		"#DOTA_WearableType_Honored_Cape"
			"model_player"		"models/items/phantom_assassin/lodas_pa_set__cape/lodas_pa_set__cape.vmdl"
			"portraits"
			{
				"icon"
				{
					"PortraitLightPosition"		"-104.916451 137.334091 203.602936"
					"PortraitLightAngles"		"43.143311 298.712769 0.000000"
					"PortraitLightFOV"		"46.000000"
					"PortraitLightDistance"		"242.000000"
					"PortraitLightColor"		"254 254 254"
					"PortraitShadowColor"		"97 97 97"
					"PortraitShadowScale"		"1.500000"
					"PortraitGroundShadowScale"		"1.500000"
					"PortraitAmbientColor"		"148 148 148"
					"PortraitAmbientScale"		"2.750000"
					"PortraitSpecularColor"		"251 74 84"
					"PortraitSpecularDirection"		"0.000000 0.000000 -1.000000"
					"PortraitSpecularPower"		"16.000000"
					"PortraitBackgroundColor1"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor2"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor3"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor4"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundTexture"		"materials/vgui/econ/item_icon_bg.vmat"
					"PortraitAnimationActivity"		"ACT_DOTA_CAPTURE"
					"PortraitAnimationCycle"		"0.272000"
					"PortraitAnimationRate"		"0.000000"
					"PortraitHideHero"		"0"
					"PortraitLightScale"		"1.750000"
					"PortraitAmbientDirection"		"197.904 4.526 -33.190"
					"cameras"
					{
						"default"
						{
							"PortraitPosition"		"-295.851105 165.136505 186.125473"
							"PortraitAngles"		"20.522461 331.534424 2.109375"
							"PortraitFOV"		"37.000000"
							"PortraitFar"		"1000.000000"
						}
					}
				}
			}
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"used_by_heroes"
			{
				"npc_dota_hero_phantom_assassin"		"1"
			}
			"branding"
			{
				"team_id"		"111474"
			}
		}
		"5656"
		{
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"used_by_heroes"
			{
				"npc_dota_hero_phantom_assassin"		"1"
			}
			"branding"
			{
				"team_id"		"111474"
			}
		}
		"5657"
		{
			"name"		"Ornaments of the Gleaming Seal"
			"prefab"		"wearable"
			"creation_date"		"2013-11-06"
			"image_inventory"		"econ/items/phantom_assassin/lodas_pa_set__shoulders/lodas_pa_set__shoulders"
			"item_description"		"#DOTA_Item_Desc_Ornaments_of_the_Gleaming_Seal"
			"item_name"		"#DOTA_Item_Ornaments_of_the_Gleaming_Seal"
			"item_rarity"		"rare"
			"item_slot"		"shoulder"
			"item_type_name"		"#DOTA_WearableType_Honored_Shoulders"
			"model_player"		"models/items/phantom_assassin/lodas_pa_set__shoulders/lodas_pa_set__shoulders.vmdl"
			"portraits"
			{
				"icon"
				{
					"PortraitLightPosition"		"76.932938 -29.410818 221.487381"
					"PortraitLightAngles"		"57.661743 141.822510 0.000000"
					"PortraitLightFOV"		"46.000000"
					"PortraitLightDistance"		"242.000000"
					"PortraitLightColor"		"254 254 254"
					"PortraitShadowColor"		"97 97 97"
					"PortraitShadowScale"		"1.500000"
					"PortraitGroundShadowScale"		"1.500000"
					"PortraitAmbientColor"		"148 148 148"
					"PortraitAmbientScale"		"2.750000"
					"PortraitSpecularColor"		"251 74 84"
					"PortraitSpecularDirection"		"0.000000 0.000000 -1.000000"
					"PortraitSpecularPower"		"16.000000"
					"PortraitBackgroundColor1"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor2"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor3"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor4"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundTexture"		"materials/vgui/econ/item_icon_bg.vmat"
					"PortraitAnimationActivity"		"ACT_DOTA_CAPTURE"
					"PortraitAnimationCycle"		"0.000000"
					"PortraitAnimationRate"		"0.000000"
					"PortraitHideHero"		"0"
					"PortraitLightScale"		"1.750000"
					"PortraitAmbientDirection"		"197.904 4.526 -33.190"
					"cameras"
					{
						"default"
						{
							"PortraitPosition"		"187.467773 -76.296227 122.148560"
							"PortraitAngles"		"357.363281 155.198364 2.109375"
							"PortraitFOV"		"24.000000"
							"PortraitFar"		"1000.000000"
						}
					}
				}
			}
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"used_by_heroes"
			{
				"npc_dota_hero_phantom_assassin"		"1"
			}
			"branding"
			{
				"team_id"		"111474"
			}
		}
		"5656"
		{
			"name"		"Brooch of the Gleaming Seal"
			"prefab"		"wearable"
			"creation_date"		"2013-11-06"
			"image_inventory"		"econ/items/phantom_assassin/lodas_pa_set__head/lodas_pa_set__head"
			"item_description"		"#DOTA_Item_Desc_Brooch_of_the_Gleaming_Seal"
			"item_name"		"#DOTA_Item_Brooch_of_the_Gleaming_Seal"
			"item_rarity"		"uncommon"
			"item_slot"		"head"
			"item_type_name"		"#DOTA_WearableType_Honored_Brooch"
			"model_player"		"models/items/phantom_assassin/lodas_pa_set__head/lodas_pa_set__head.vmdl"
			"portraits"
			{
				"icon"
				{
					"PortraitLightPosition"		"76.932938 -29.410818 221.487381"
					"PortraitLightAngles"		"38.671875 155.000610 0.000000"
					"PortraitLightFOV"		"34.000000"
					"PortraitLightDistance"		"130.000000"
					"PortraitLightColor"		"254 254 254"
					"PortraitShadowColor"		"97 97 97"
					"PortraitShadowScale"		"1.500000"
					"PortraitGroundShadowScale"		"1.500000"
					"PortraitAmbientColor"		"148 148 148"
					"PortraitAmbientScale"		"2.750000"
					"PortraitSpecularColor"		"251 74 84"
					"PortraitSpecularDirection"		"0.000000 0.000000 -1.000000"
					"PortraitSpecularPower"		"16.000000"
					"PortraitBackgroundColor1"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor2"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor3"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor4"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundTexture"		"materials/vgui/econ/item_icon_bg.vmat"
					"PortraitAnimationActivity"		"ACT_DOTA_CAPTURE"
					"PortraitAnimationCycle"		"0.000000"
					"PortraitAnimationRate"		"0.000000"
					"PortraitHideHero"		"0"
					"PortraitLightScale"		"1.750000"
					"PortraitAmbientDirection"		"197.904 4.526 -33.190"
					"cameras"
					{
						"default"
						{
							"PortraitPosition"		"187.467773 -76.296227 122.148560"
							"PortraitAngles"		"351.513062 155.308228 2.109375"
							"PortraitFOV"		"23.000000"
							"PortraitFar"		"1000.000000"
						}
					}
				}
			}
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"branding"
			{
				"team_id"		"111474"
			}
		}
		"5657"
		{
			"name"		"Ornaments of the Gleaming Seal"
			"prefab"		"wearable"
			"creation_date"		"2013-11-06"
			"image_inventory"		"econ/items/phantom_assassin/lodas_pa_set__shoulders/lodas_pa_set__shoulders"
			"item_description"		"#DOTA_Item_Desc_Ornaments_of_the_Gleaming_Seal"
			"item_name"		"#DOTA_Item_Ornaments_of_the_Gleaming_Seal"
			"item_rarity"		"rare"
			"item_slot"		"shoulder"
			"item_type_name"		"#DOTA_WearableType_Honored_Shoulders"
			"model_player"		"models/items/phantom_assassin/lodas_pa_set__shoulders/lodas_pa_set__shoulders.vmdl"
			"portraits"
			{
				"icon"
				{
					"PortraitLightPosition"		"76.932938 -29.410818 221.487381"
					"PortraitLightAngles"		"57.661743 141.822510 0.000000"
					"PortraitLightFOV"		"46.000000"
					"PortraitLightDistance"		"242.000000"
					"PortraitLightColor"		"254 254 254"
					"PortraitShadowColor"		"97 97 97"
					"PortraitShadowScale"		"1.500000"
					"PortraitGroundShadowScale"		"1.500000"
					"PortraitAmbientColor"		"148 148 148"
					"PortraitAmbientScale"		"2.750000"
					"PortraitSpecularColor"		"251 74 84"
					"PortraitSpecularDirection"		"0.000000 0.000000 -1.000000"
					"PortraitSpecularPower"		"16.000000"
					"PortraitBackgroundColor1"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor2"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor3"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor4"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundTexture"		"materials/vgui/econ/item_icon_bg.vmat"
					"PortraitAnimationActivity"		"ACT_DOTA_CAPTURE"
					"PortraitAnimationCycle"		"0.000000"
					"PortraitAnimationRate"		"0.000000"
					"PortraitHideHero"		"0"
					"PortraitLightScale"		"1.750000"
					"PortraitAmbientDirection"		"197.904 4.526 -33.190"
					"cameras"
					{
						"default"
						{
							"PortraitPosition"		"187.467773 -76.296227 122.148560"
							"PortraitAngles"		"357.363281 155.198364 2.109375"
							"PortraitFOV"		"24.000000"
							"PortraitFar"		"1000.000000"
						}
					}
				}
			}
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"used_by_heroes"
			{
				"npc_dota_hero_phantom_assassin"		"1"
			}
			"branding"
			{
				"team_id"		"111474"
			}
		}
		"5656"
		{
			"name"		"Brooch of the Gleaming Seal"
			"prefab"		"wearable"
			"creation_date"		"2013-11-06"
			"image_inventory"		"econ/items/phantom_assassin/lodas_pa_set__head/lodas_pa_set__head"
			"item_description"		"#DOTA_Item_Desc_Brooch_of_the_Gleaming_Seal"
			"item_name"		"#DOTA_Item_Brooch_of_the_Gleaming_Seal"
			"item_rarity"		"uncommon"
			"item_slot"		"head"
			"item_type_name"		"#DOTA_WearableType_Honored_Brooch"
			"model_player"		"models/items/phantom_assassin/lodas_pa_set__head/lodas_pa_set__head.vmdl"
			"portraits"
			{
				"icon"
				{
					"PortraitLightPosition"		"76.932938 -29.410818 221.487381"
					"PortraitLightAngles"		"38.671875 155.000610 0.000000"
					"PortraitLightFOV"		"34.000000"
					"PortraitLightDistance"		"130.000000"
					"PortraitLightColor"		"254 254 254"
					"PortraitShadowColor"		"97 97 97"
					"PortraitShadowScale"		"1.500000"
					"PortraitGroundShadowScale"		"1.500000"
					"PortraitAmbientColor"		"148 148 148"
					"PortraitAmbientScale"		"2.750000"
					"PortraitSpecularColor"		"251 74 84"
					"PortraitSpecularDirection"		"0.000000 0.000000 -1.000000"
					"PortraitSpecularPower"		"16.000000"
					"PortraitBackgroundColor1"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor2"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor3"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor4"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundTexture"		"materials/vgui/econ/item_icon_bg.vmat"
					"PortraitAnimationActivity"		"ACT_DOTA_CAPTURE"
					"PortraitAnimationCycle"		"0.000000"
					"PortraitAnimationRate"		"0.000000"
					"PortraitHideHero"		"0"
					"PortraitLightScale"		"1.750000"
					"PortraitAmbientDirection"		"197.904 4.526 -33.190"
					"cameras"
					{
						"default"
						{
							"PortraitPosition"		"187.467773 -76.296227 122.148560"
							"PortraitAngles"		"351.513062 155.308228 2.109375"
							"PortraitFOV"		"23.000000"
							"PortraitFar"		"1000.000000"
						}
					}
				}
			}
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"used_by_heroes"
			{
				"npc_dota_hero_phantom_assassin"		"1"
			}
			"branding"
			{
				"team_id"		"111474"
			}
		}

)
RegExMatch(Haystack2,"i s)\t\t\}\R\t\t""5656""\R\t\t\{*[^{}]*""prefab""[^{}]*{*[^{}]*""used_by_heroes""[^{}].*?\R\t\t\}",found)
MsgBox % found
[/color]
Developer of AJOM's DOTA2 MOD Master, Easiest way to MOD your DOTA2 without the use of internet :lol: . I created this program using Autohotkey thats why I love Autohotkey and the community!

GitHub:
https://github.com/Aldrin-John-Olaer-Manalansan
User avatar
Datapoint
Posts: 294
Joined: 18 Mar 2018, 17:06

Re: Condition that a "WORD" is inside a Matched "algorithm" on RegExMatch Operation

23 Jul 2018, 22:33

Code: Select all

; Note the first "5656" block does not contain "prefab" but the second one does.
Haystack = 
(Join`r`n
		}
		"5654"
		{
			"name"		"Belt of the Gleaming Seal"
			"prefab"		"wearable"
			"creation_date"		"2013-11-06"
			"image_inventory"		"econ/items/phantom_assassin/lodas_pa_set__belt/lodas_pa_set__belt"
			"item_description"		"#DOTA_Item_Desc_Belt_of_the_Gleaming_Seal"
			"item_name"		"#DOTA_Item_Belt_of_the_Gleaming_Seal"
			"item_slot"		"belt"
			"item_type_name"		"#DOTA_WearableType_Honored_Belt"
			"model_player"		"models/items/phantom_assassin/lodas_pa_set__belt/lodas_pa_set__belt.vmdl"
			"portraits"
			{
				"icon"
				{
					"PortraitLightPosition"		"76.932938 -29.410818 221.487381"
					"PortraitLightAngles"		"57.661743 141.822510 0.000000"
					"PortraitLightFOV"		"46.000000"
					"PortraitLightDistance"		"242.000000"
					"PortraitLightColor"		"254 254 254"
					"PortraitShadowColor"		"97 97 97"
					"PortraitShadowScale"		"1.500000"
					"PortraitGroundShadowScale"		"1.500000"
					"PortraitAmbientColor"		"148 148 148"
					"PortraitAmbientScale"		"2.750000"
					"PortraitSpecularColor"		"251 74 84"
					"PortraitSpecularDirection"		"0.000000 0.000000 -1.000000"
					"PortraitSpecularPower"		"16.000000"
					"PortraitBackgroundColor1"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor2"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor3"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor4"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundTexture"		"materials/vgui/econ/item_icon_bg.vmat"
					"PortraitAnimationActivity"		"ACT_DOTA_CAPTURE"
					"PortraitAnimationCycle"		"0.000000"
					"PortraitAnimationRate"		"0.000000"
					"PortraitHideHero"		"0"
					"PortraitLightScale"		"1.750000"
					"PortraitAmbientDirection"		"197.904 4.526 -33.190"
					"cameras"
					{
						"default"
						{
							"PortraitPosition"		"182.981750 -85.518150 126.108841"
							"PortraitAngles"		"8.997803 154.621582 2.109375"
							"PortraitFOV"		"22.000000"
							"PortraitFar"		"1000.000000"
						}
					}
				}
			}
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"used_by_heroes"
			{
				"npc_dota_hero_phantom_assassin"		"1"
			}
			"branding"
			{
				"team_id"		"111474"
			}
		}
		"5655"
		{
			"name"		"Cape of the Gleaming Seal"
			"prefab"		"wearable"
			"creation_date"		"2013-11-06"
			"image_inventory"		"econ/items/phantom_assassin/lodas_pa_set__cape/lodas_pa_set__cape"
			"item_description"		"#DOTA_Item_Desc_Cape_of_the_Gleaming_Seal"
			"item_name"		"#DOTA_Item_Cape_of_the_Gleaming_Seal"
			"item_slot"		"back"
			"item_type_name"		"#DOTA_WearableType_Honored_Cape"
			"model_player"		"models/items/phantom_assassin/lodas_pa_set__cape/lodas_pa_set__cape.vmdl"
			"portraits"
			{
				"icon"
				{
					"PortraitLightPosition"		"-104.916451 137.334091 203.602936"
					"PortraitLightAngles"		"43.143311 298.712769 0.000000"
					"PortraitLightFOV"		"46.000000"
					"PortraitLightDistance"		"242.000000"
					"PortraitLightColor"		"254 254 254"
					"PortraitShadowColor"		"97 97 97"
					"PortraitShadowScale"		"1.500000"
					"PortraitGroundShadowScale"		"1.500000"
					"PortraitAmbientColor"		"148 148 148"
					"PortraitAmbientScale"		"2.750000"
					"PortraitSpecularColor"		"251 74 84"
					"PortraitSpecularDirection"		"0.000000 0.000000 -1.000000"
					"PortraitSpecularPower"		"16.000000"
					"PortraitBackgroundColor1"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor2"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor3"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor4"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundTexture"		"materials/vgui/econ/item_icon_bg.vmat"
					"PortraitAnimationActivity"		"ACT_DOTA_CAPTURE"
					"PortraitAnimationCycle"		"0.272000"
					"PortraitAnimationRate"		"0.000000"
					"PortraitHideHero"		"0"
					"PortraitLightScale"		"1.750000"
					"PortraitAmbientDirection"		"197.904 4.526 -33.190"
					"cameras"
					{
						"default"
						{
							"PortraitPosition"		"-295.851105 165.136505 186.125473"
							"PortraitAngles"		"20.522461 331.534424 2.109375"
							"PortraitFOV"		"37.000000"
							"PortraitFar"		"1000.000000"
						}
					}
				}
			}
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"used_by_heroes"
			{
				"npc_dota_hero_phantom_assassin"		"1"
			}
			"branding"
			{
				"team_id"		"111474"
			}
		}
		"5656"
		{
			"name"		"Brooch of the Gleaming Seal"
			"creation_date"		"2013-11-06"
			"image_inventory"		"econ/items/phantom_assassin/lodas_pa_set__head/lodas_pa_set__head"
			"item_description"		"#DOTA_Item_Desc_Brooch_of_the_Gleaming_Seal"
			"item_name"		"#DOTA_Item_Brooch_of_the_Gleaming_Seal"
			"item_rarity"		"uncommon"
			"item_slot"		"head"
			"item_type_name"		"#DOTA_WearableType_Honored_Brooch"
			"model_player"		"models/items/phantom_assassin/lodas_pa_set__head/lodas_pa_set__head.vmdl"
			"portraits"
			{
				"icon"
				{
					"PortraitLightPosition"		"76.932938 -29.410818 221.487381"
					"PortraitLightAngles"		"38.671875 155.000610 0.000000"
					"PortraitLightFOV"		"34.000000"
					"PortraitLightDistance"		"130.000000"
					"PortraitLightColor"		"254 254 254"
					"PortraitShadowColor"		"97 97 97"
					"PortraitShadowScale"		"1.500000"
					"PortraitGroundShadowScale"		"1.500000"
					"PortraitAmbientColor"		"148 148 148"
					"PortraitAmbientScale"		"2.750000"
					"PortraitSpecularColor"		"251 74 84"
					"PortraitSpecularDirection"		"0.000000 0.000000 -1.000000"
					"PortraitSpecularPower"		"16.000000"
					"PortraitBackgroundColor1"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor2"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor3"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor4"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundTexture"		"materials/vgui/econ/item_icon_bg.vmat"
					"PortraitAnimationActivity"		"ACT_DOTA_CAPTURE"
					"PortraitAnimationCycle"		"0.000000"
					"PortraitAnimationRate"		"0.000000"
					"PortraitHideHero"		"0"
					"PortraitLightScale"		"1.750000"
					"PortraitAmbientDirection"		"197.904 4.526 -33.190"
					"cameras"
					{
						"default"
						{
							"PortraitPosition"		"187.467773 -76.296227 122.148560"
							"PortraitAngles"		"351.513062 155.308228 2.109375"
							"PortraitFOV"		"23.000000"
							"PortraitFar"		"1000.000000"
						}
					}
				}
			}
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"used_by_heroes"
			{
				"npc_dota_hero_phantom_assassin"		"1"
			}
			"branding"
			{
				"team_id"		"111474"
			}
		}
		"5656"
		{
			"name"		"Brooch of the Gleaming Seal"
			"prefab"		"wearable"
			"creation_date"		"2013-11-06"
			"image_inventory"		"econ/items/phantom_assassin/lodas_pa_set__head/lodas_pa_set__head"
			"item_description"		"#DOTA_Item_Desc_Brooch_of_the_Gleaming_Seal"
			"item_name"		"#DOTA_Item_Brooch_of_the_Gleaming_Seal"
			"item_rarity"		"uncommon"
			"item_slot"		"head"
			"item_type_name"		"#DOTA_WearableType_Honored_Brooch"
			"model_player"		"models/items/phantom_assassin/lodas_pa_set__head/lodas_pa_set__head.vmdl"
			"portraits"
			{
				"icon"
				{
					"PortraitLightPosition"		"76.932938 -29.410818 221.487381"
					"PortraitLightAngles"		"38.671875 155.000610 0.000000"
					"PortraitLightFOV"		"34.000000"
					"PortraitLightDistance"		"130.000000"
					"PortraitLightColor"		"254 254 254"
					"PortraitShadowColor"		"97 97 97"
					"PortraitShadowScale"		"1.500000"
					"PortraitGroundShadowScale"		"1.500000"
					"PortraitAmbientColor"		"148 148 148"
					"PortraitAmbientScale"		"2.750000"
					"PortraitSpecularColor"		"251 74 84"
					"PortraitSpecularDirection"		"0.000000 0.000000 -1.000000"
					"PortraitSpecularPower"		"16.000000"
					"PortraitBackgroundColor1"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor2"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor3"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor4"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundTexture"		"materials/vgui/econ/item_icon_bg.vmat"
					"PortraitAnimationActivity"		"ACT_DOTA_CAPTURE"
					"PortraitAnimationCycle"		"0.000000"
					"PortraitAnimationRate"		"0.000000"
					"PortraitHideHero"		"0"
					"PortraitLightScale"		"1.750000"
					"PortraitAmbientDirection"		"197.904 4.526 -33.190"
					"cameras"
					{
						"default"
						{
							"PortraitPosition"		"187.467773 -76.296227 122.148560"
							"PortraitAngles"		"351.513062 155.308228 2.109375"
							"PortraitFOV"		"23.000000"
							"PortraitFar"		"1000.000000"
						}
					}
				}
			}
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"used_by_heroes"
			{
				"npc_dota_hero_phantom_assassin"		"1"
			}
			"branding"
			{
				"team_id"		"111474"
			}
		}
		"5657"
		{
			"name"		"Ornaments of the Gleaming Seal"
			"prefab"		"wearable"
			"creation_date"		"2013-11-06"
			"image_inventory"		"econ/items/phantom_assassin/lodas_pa_set__shoulders/lodas_pa_set__shoulders"
			"item_description"		"#DOTA_Item_Desc_Ornaments_of_the_Gleaming_Seal"
			"item_name"		"#DOTA_Item_Ornaments_of_the_Gleaming_Seal"
			"item_rarity"		"rare"
			"item_slot"		"shoulder"
			"item_type_name"		"#DOTA_WearableType_Honored_Shoulders"
			"model_player"		"models/items/phantom_assassin/lodas_pa_set__shoulders/lodas_pa_set__shoulders.vmdl"
			"portraits"
			{
				"icon"
				{
					"PortraitLightPosition"		"76.932938 -29.410818 221.487381"
					"PortraitLightAngles"		"57.661743 141.822510 0.000000"
					"PortraitLightFOV"		"46.000000"
					"PortraitLightDistance"		"242.000000"
					"PortraitLightColor"		"254 254 254"
					"PortraitShadowColor"		"97 97 97"
					"PortraitShadowScale"		"1.500000"
					"PortraitGroundShadowScale"		"1.500000"
					"PortraitAmbientColor"		"148 148 148"
					"PortraitAmbientScale"		"2.750000"
					"PortraitSpecularColor"		"251 74 84"
					"PortraitSpecularDirection"		"0.000000 0.000000 -1.000000"
					"PortraitSpecularPower"		"16.000000"
					"PortraitBackgroundColor1"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor2"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor3"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor4"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundTexture"		"materials/vgui/econ/item_icon_bg.vmat"
					"PortraitAnimationActivity"		"ACT_DOTA_CAPTURE"
					"PortraitAnimationCycle"		"0.000000"
					"PortraitAnimationRate"		"0.000000"
					"PortraitHideHero"		"0"
					"PortraitLightScale"		"1.750000"
					"PortraitAmbientDirection"		"197.904 4.526 -33.190"
					"cameras"
					{
						"default"
						{
							"PortraitPosition"		"187.467773 -76.296227 122.148560"
							"PortraitAngles"		"357.363281 155.198364 2.109375"
							"PortraitFOV"		"24.000000"
							"PortraitFar"		"1000.000000"
						}
					}
				}
			}
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"used_by_heroes"
			{
				"npc_dota_hero_phantom_assassin"		"1"
			}
			"branding"
			{
				"team_id"		"111474"
			}
		}
)

; 1st option------------------------------------------------------------------------------------------------------------
/*  from: https://regex101.com/r/VHzUsz/1
 *     /
 *     (^|\R)\K\s*"5656"\R\s+\{[^{}]*"prefab"[^{}]*\{(?:[^}]*\}){8}
 *     /
 *     1st Capturing Group (^|\R)
 *         1st Alternative ^
 *             ^ asserts position at start of the string
 *         2nd Alternative \R
 *             \R matches any Unicode newline sequence; can be modified using verbs
 *     \K resets the starting point of the reported match. Any previously consumed characters are no longer included in the final match
 *     \s*
 *         matches any whitespace character (equal to [\r\n\t\f\v ])
 *         * Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)
 *     "5656" matches the characters "5656" literally (case sensitive)
 *     \R matches any Unicode newline sequence; can be modified using verbs
 *     \s+
 *         matches any whitespace character (equal to [\r\n\t\f\v ])
 *         + Quantifier — Matches between one and unlimited times, as many times as possible, giving back as needed (greedy)
 *     \{ matches the character { literally (case sensitive)
 *     Match a single character not present in the list below [^{}]*
 *         * Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)
 *         {} matches a single character in the list {} (case sensitive)
 *     "prefab" matches the characters "prefab" literally (case sensitive)
 *     Match a single character not present in the list below [^{}]*
 *         * Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)
 *         {} matches a single character in the list {} (case sensitive)
 *     \{ matches the character { literally (case sensitive)
 *     Non-capturing group (?:[^}]*\}){8}
 *     {8} Quantifier — Matches exactly 8 times
 *     Match a single character not present in the list below [^}]*
 *     \} matches the character } literally (case sensitive)
 */

; This regex is if you will always have the same number of braces ("{" and "}").
; The key to understanding this is that "[^{}]" means "any character that is not { or }".
RegExMatch(Haystack, "`a)(^|\R)\K\s*""5656""\R\s+\{[^{}]*""prefab""[^{}]*\{(?:[^}]*\}){8}", UnquotedOutputVar)
MsgBox,, 1st Option, % UnquotedOutputVar
;-----------------------------------------------------------------------------------------------------------------------


; 2nd option------------------------------------------------------------------------------------------------------------
/*  from https://regex101.com/r/VHzUsz/2
 *     /
 *     (?:^|\R)\K\s*"5656"\R\s+(\{(?>[^{}]|(?1))*\})
 *     /
 *     ms
 *     Non-capturing group (?:^|\R)
 *         1st Alternative ^
 *             ^ asserts position at start of a line
 *         2nd Alternative \R
 *             \R matches any Unicode newline sequence; can be modified using verbs
 *     \K resets the starting point of the reported match. Any previously consumed characters are no longer included in the final match
 *     \s*
 *         matches any whitespace character (equal to [\r\n\t\f\v ])
 *         * Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)
 *     "5656" matches the characters "5656" literally (case sensitive)
 *     \R matches any Unicode newline sequence; can be modified using verbs
 *     \s+
 *         matches any whitespace character (equal to [\r\n\t\f\v ])
 *         + Quantifier — Matches between one and unlimited times, as many times as possible, giving back as needed (greedy)
 *     1st Capturing Group (\{(?>[^{}]|(?1))*\})
 *         \{ matches the character { literally (case sensitive)
 *         Atomic Group (?>[^{}]|(?1))*
 *             This group does not allow any backtracking to occur
 *             * Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)
 *             1st Alternative [^{}]
 *                 Match a single character not present in the list below [^{}]
 *                 {} matches a single character in the list {} (case sensitive)
 *             2nd Alternative (?1)
 *                 (?1) recurses the 1st subpattern
 *     \} matches the character } literally (case sensitive)
 *     Global pattern flags
 *     m modifier: multi line. Causes ^ and $ to match the begin/end of each line (not only begin/end of string)
 *     s modifier: single line. Dot matches newline characters 
 */

; This uses regex recusion (see: Matching Balanced Constructs https://www.regular-expressions.info/recurse.html)
; It will always match a balanced number of { and }, but it requires an extra step (the while loop) to check if the
; match contains "prefab".
StartingPosition := 1, Result := ""
while FoundPos := RegExMatch(Haystack, "`a)(?:^|\R)\K\s*""5656""\R\s+(\{(?>[^{}]|(?1))*\})", UnquotedOutputVar, StartingPosition)
{
    ; MsgBox % A_Index
    if InStr(UnquotedOutputVar, """prefab""")
    {
        Result := UnquotedOutputVar
        break
    }
    else
        StartingPosition := FoundPos + StrLen(UnquotedOutputVar)
}
MsgBox,, 2nd Option, % Result
;-----------------------------------------------------------------------------------------------------------------------


; 3rd option------------------------------------------------------------------------------------------------------------
/*  from https://autohotkey.com/boards/viewtopic.php?p=229951#p229951
 *     I think the RegExMatch should do is:
 *     1)search for this word "%A_Tab%%A_Tab%}`r`n%A_Tab%%A_Tab%"5656"`r`n%A_Tab%%A_Tab%{"
 *     2)consume anything after that word until encountering this word "`r`n%A_Tab%%A_Tab%}"
 *     3)if the matched case has a word "prefab" then stop searching and put to variable. else find another match
 *     
 *     see explanation at https://regex101.com/r/VHzUsz/3
 */
StartingPosition := 1, Result := ""
while FoundPos := RegExMatch(Haystack, "`ams)^`t`t""5656""\R`t`t\{.*?\R`t`t\}", UnquotedOutputVar, StartingPosition)
{   
    ; MsgBox % A_Index
    if InStr(UnquotedOutputVar, """prefab""")
    {
        Result := UnquotedOutputVar
        break
    }
    else
        StartingPosition := FoundPos + StrLen(UnquotedOutputVar)
}
MsgBox,, 3rd Option, % Result
;-----------------------------------------------------------------------------------------------------------------------
aldrinjohnom
Posts: 77
Joined: 18 Apr 2018, 08:49

Re: Condition that a "WORD" is inside a Matched "algorithm" on RegExMatch Operation

23 Jul 2018, 23:26

Datapoint wrote:

Code: Select all

; Note the first "5656" block does not contain "prefab" but the second one does.
Haystack = 
(Join`r`n
		}
		"5654"
		{
			"name"		"Belt of the Gleaming Seal"
			"prefab"		"wearable"
			"creation_date"		"2013-11-06"
			"image_inventory"		"econ/items/phantom_assassin/lodas_pa_set__belt/lodas_pa_set__belt"
			"item_description"		"#DOTA_Item_Desc_Belt_of_the_Gleaming_Seal"
			"item_name"		"#DOTA_Item_Belt_of_the_Gleaming_Seal"
			"item_slot"		"belt"
			"item_type_name"		"#DOTA_WearableType_Honored_Belt"
			"model_player"		"models/items/phantom_assassin/lodas_pa_set__belt/lodas_pa_set__belt.vmdl"
			"portraits"
			{
				"icon"
				{
					"PortraitLightPosition"		"76.932938 -29.410818 221.487381"
					"PortraitLightAngles"		"57.661743 141.822510 0.000000"
					"PortraitLightFOV"		"46.000000"
					"PortraitLightDistance"		"242.000000"
					"PortraitLightColor"		"254 254 254"
					"PortraitShadowColor"		"97 97 97"
					"PortraitShadowScale"		"1.500000"
					"PortraitGroundShadowScale"		"1.500000"
					"PortraitAmbientColor"		"148 148 148"
					"PortraitAmbientScale"		"2.750000"
					"PortraitSpecularColor"		"251 74 84"
					"PortraitSpecularDirection"		"0.000000 0.000000 -1.000000"
					"PortraitSpecularPower"		"16.000000"
					"PortraitBackgroundColor1"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor2"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor3"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor4"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundTexture"		"materials/vgui/econ/item_icon_bg.vmat"
					"PortraitAnimationActivity"		"ACT_DOTA_CAPTURE"
					"PortraitAnimationCycle"		"0.000000"
					"PortraitAnimationRate"		"0.000000"
					"PortraitHideHero"		"0"
					"PortraitLightScale"		"1.750000"
					"PortraitAmbientDirection"		"197.904 4.526 -33.190"
					"cameras"
					{
						"default"
						{
							"PortraitPosition"		"182.981750 -85.518150 126.108841"
							"PortraitAngles"		"8.997803 154.621582 2.109375"
							"PortraitFOV"		"22.000000"
							"PortraitFar"		"1000.000000"
						}
					}
				}
			}
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"used_by_heroes"
			{
				"npc_dota_hero_phantom_assassin"		"1"
			}
			"branding"
			{
				"team_id"		"111474"
			}
		}
		"5655"
		{
			"name"		"Cape of the Gleaming Seal"
			"prefab"		"wearable"
			"creation_date"		"2013-11-06"
			"image_inventory"		"econ/items/phantom_assassin/lodas_pa_set__cape/lodas_pa_set__cape"
			"item_description"		"#DOTA_Item_Desc_Cape_of_the_Gleaming_Seal"
			"item_name"		"#DOTA_Item_Cape_of_the_Gleaming_Seal"
			"item_slot"		"back"
			"item_type_name"		"#DOTA_WearableType_Honored_Cape"
			"model_player"		"models/items/phantom_assassin/lodas_pa_set__cape/lodas_pa_set__cape.vmdl"
			"portraits"
			{
				"icon"
				{
					"PortraitLightPosition"		"-104.916451 137.334091 203.602936"
					"PortraitLightAngles"		"43.143311 298.712769 0.000000"
					"PortraitLightFOV"		"46.000000"
					"PortraitLightDistance"		"242.000000"
					"PortraitLightColor"		"254 254 254"
					"PortraitShadowColor"		"97 97 97"
					"PortraitShadowScale"		"1.500000"
					"PortraitGroundShadowScale"		"1.500000"
					"PortraitAmbientColor"		"148 148 148"
					"PortraitAmbientScale"		"2.750000"
					"PortraitSpecularColor"		"251 74 84"
					"PortraitSpecularDirection"		"0.000000 0.000000 -1.000000"
					"PortraitSpecularPower"		"16.000000"
					"PortraitBackgroundColor1"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor2"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor3"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor4"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundTexture"		"materials/vgui/econ/item_icon_bg.vmat"
					"PortraitAnimationActivity"		"ACT_DOTA_CAPTURE"
					"PortraitAnimationCycle"		"0.272000"
					"PortraitAnimationRate"		"0.000000"
					"PortraitHideHero"		"0"
					"PortraitLightScale"		"1.750000"
					"PortraitAmbientDirection"		"197.904 4.526 -33.190"
					"cameras"
					{
						"default"
						{
							"PortraitPosition"		"-295.851105 165.136505 186.125473"
							"PortraitAngles"		"20.522461 331.534424 2.109375"
							"PortraitFOV"		"37.000000"
							"PortraitFar"		"1000.000000"
						}
					}
				}
			}
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"used_by_heroes"
			{
				"npc_dota_hero_phantom_assassin"		"1"
			}
			"branding"
			{
				"team_id"		"111474"
			}
		}
		"5656"
		{
			"name"		"Brooch of the Gleaming Seal"
			"creation_date"		"2013-11-06"
			"image_inventory"		"econ/items/phantom_assassin/lodas_pa_set__head/lodas_pa_set__head"
			"item_description"		"#DOTA_Item_Desc_Brooch_of_the_Gleaming_Seal"
			"item_name"		"#DOTA_Item_Brooch_of_the_Gleaming_Seal"
			"item_rarity"		"uncommon"
			"item_slot"		"head"
			"item_type_name"		"#DOTA_WearableType_Honored_Brooch"
			"model_player"		"models/items/phantom_assassin/lodas_pa_set__head/lodas_pa_set__head.vmdl"
			"portraits"
			{
				"icon"
				{
					"PortraitLightPosition"		"76.932938 -29.410818 221.487381"
					"PortraitLightAngles"		"38.671875 155.000610 0.000000"
					"PortraitLightFOV"		"34.000000"
					"PortraitLightDistance"		"130.000000"
					"PortraitLightColor"		"254 254 254"
					"PortraitShadowColor"		"97 97 97"
					"PortraitShadowScale"		"1.500000"
					"PortraitGroundShadowScale"		"1.500000"
					"PortraitAmbientColor"		"148 148 148"
					"PortraitAmbientScale"		"2.750000"
					"PortraitSpecularColor"		"251 74 84"
					"PortraitSpecularDirection"		"0.000000 0.000000 -1.000000"
					"PortraitSpecularPower"		"16.000000"
					"PortraitBackgroundColor1"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor2"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor3"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor4"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundTexture"		"materials/vgui/econ/item_icon_bg.vmat"
					"PortraitAnimationActivity"		"ACT_DOTA_CAPTURE"
					"PortraitAnimationCycle"		"0.000000"
					"PortraitAnimationRate"		"0.000000"
					"PortraitHideHero"		"0"
					"PortraitLightScale"		"1.750000"
					"PortraitAmbientDirection"		"197.904 4.526 -33.190"
					"cameras"
					{
						"default"
						{
							"PortraitPosition"		"187.467773 -76.296227 122.148560"
							"PortraitAngles"		"351.513062 155.308228 2.109375"
							"PortraitFOV"		"23.000000"
							"PortraitFar"		"1000.000000"
						}
					}
				}
			}
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"used_by_heroes"
			{
				"npc_dota_hero_phantom_assassin"		"1"
			}
			"branding"
			{
				"team_id"		"111474"
			}
		}
		"5656"
		{
			"name"		"Brooch of the Gleaming Seal"
			"prefab"		"wearable"
			"creation_date"		"2013-11-06"
			"image_inventory"		"econ/items/phantom_assassin/lodas_pa_set__head/lodas_pa_set__head"
			"item_description"		"#DOTA_Item_Desc_Brooch_of_the_Gleaming_Seal"
			"item_name"		"#DOTA_Item_Brooch_of_the_Gleaming_Seal"
			"item_rarity"		"uncommon"
			"item_slot"		"head"
			"item_type_name"		"#DOTA_WearableType_Honored_Brooch"
			"model_player"		"models/items/phantom_assassin/lodas_pa_set__head/lodas_pa_set__head.vmdl"
			"portraits"
			{
				"icon"
				{
					"PortraitLightPosition"		"76.932938 -29.410818 221.487381"
					"PortraitLightAngles"		"38.671875 155.000610 0.000000"
					"PortraitLightFOV"		"34.000000"
					"PortraitLightDistance"		"130.000000"
					"PortraitLightColor"		"254 254 254"
					"PortraitShadowColor"		"97 97 97"
					"PortraitShadowScale"		"1.500000"
					"PortraitGroundShadowScale"		"1.500000"
					"PortraitAmbientColor"		"148 148 148"
					"PortraitAmbientScale"		"2.750000"
					"PortraitSpecularColor"		"251 74 84"
					"PortraitSpecularDirection"		"0.000000 0.000000 -1.000000"
					"PortraitSpecularPower"		"16.000000"
					"PortraitBackgroundColor1"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor2"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor3"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor4"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundTexture"		"materials/vgui/econ/item_icon_bg.vmat"
					"PortraitAnimationActivity"		"ACT_DOTA_CAPTURE"
					"PortraitAnimationCycle"		"0.000000"
					"PortraitAnimationRate"		"0.000000"
					"PortraitHideHero"		"0"
					"PortraitLightScale"		"1.750000"
					"PortraitAmbientDirection"		"197.904 4.526 -33.190"
					"cameras"
					{
						"default"
						{
							"PortraitPosition"		"187.467773 -76.296227 122.148560"
							"PortraitAngles"		"351.513062 155.308228 2.109375"
							"PortraitFOV"		"23.000000"
							"PortraitFar"		"1000.000000"
						}
					}
				}
			}
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"used_by_heroes"
			{
				"npc_dota_hero_phantom_assassin"		"1"
			}
			"branding"
			{
				"team_id"		"111474"
			}
		}
		"5657"
		{
			"name"		"Ornaments of the Gleaming Seal"
			"prefab"		"wearable"
			"creation_date"		"2013-11-06"
			"image_inventory"		"econ/items/phantom_assassin/lodas_pa_set__shoulders/lodas_pa_set__shoulders"
			"item_description"		"#DOTA_Item_Desc_Ornaments_of_the_Gleaming_Seal"
			"item_name"		"#DOTA_Item_Ornaments_of_the_Gleaming_Seal"
			"item_rarity"		"rare"
			"item_slot"		"shoulder"
			"item_type_name"		"#DOTA_WearableType_Honored_Shoulders"
			"model_player"		"models/items/phantom_assassin/lodas_pa_set__shoulders/lodas_pa_set__shoulders.vmdl"
			"portraits"
			{
				"icon"
				{
					"PortraitLightPosition"		"76.932938 -29.410818 221.487381"
					"PortraitLightAngles"		"57.661743 141.822510 0.000000"
					"PortraitLightFOV"		"46.000000"
					"PortraitLightDistance"		"242.000000"
					"PortraitLightColor"		"254 254 254"
					"PortraitShadowColor"		"97 97 97"
					"PortraitShadowScale"		"1.500000"
					"PortraitGroundShadowScale"		"1.500000"
					"PortraitAmbientColor"		"148 148 148"
					"PortraitAmbientScale"		"2.750000"
					"PortraitSpecularColor"		"251 74 84"
					"PortraitSpecularDirection"		"0.000000 0.000000 -1.000000"
					"PortraitSpecularPower"		"16.000000"
					"PortraitBackgroundColor1"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor2"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor3"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor4"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundTexture"		"materials/vgui/econ/item_icon_bg.vmat"
					"PortraitAnimationActivity"		"ACT_DOTA_CAPTURE"
					"PortraitAnimationCycle"		"0.000000"
					"PortraitAnimationRate"		"0.000000"
					"PortraitHideHero"		"0"
					"PortraitLightScale"		"1.750000"
					"PortraitAmbientDirection"		"197.904 4.526 -33.190"
					"cameras"
					{
						"default"
						{
							"PortraitPosition"		"187.467773 -76.296227 122.148560"
							"PortraitAngles"		"357.363281 155.198364 2.109375"
							"PortraitFOV"		"24.000000"
							"PortraitFar"		"1000.000000"
						}
					}
				}
			}
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"used_by_heroes"
			{
				"npc_dota_hero_phantom_assassin"		"1"
			}
			"branding"
			{
				"team_id"		"111474"
			}
		}
)

; 1st option------------------------------------------------------------------------------------------------------------
/*  from: https://regex101.com/r/VHzUsz/1
 *     /
 *     (^|\R)\K\s*"5656"\R\s+\{[^{}]*"prefab"[^{}]*\{(?:[^}]*\}){8}
 *     /
 *     1st Capturing Group (^|\R)
 *         1st Alternative ^
 *             ^ asserts position at start of the string
 *         2nd Alternative \R
 *             \R matches any Unicode newline sequence; can be modified using verbs
 *     \K resets the starting point of the reported match. Any previously consumed characters are no longer included in the final match
 *     \s*
 *         matches any whitespace character (equal to [\r\n\t\f\v ])
 *         * Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)
 *     "5656" matches the characters "5656" literally (case sensitive)
 *     \R matches any Unicode newline sequence; can be modified using verbs
 *     \s+
 *         matches any whitespace character (equal to [\r\n\t\f\v ])
 *         + Quantifier — Matches between one and unlimited times, as many times as possible, giving back as needed (greedy)
 *     \{ matches the character { literally (case sensitive)
 *     Match a single character not present in the list below [^{}]*
 *         * Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)
 *         {} matches a single character in the list {} (case sensitive)
 *     "prefab" matches the characters "prefab" literally (case sensitive)
 *     Match a single character not present in the list below [^{}]*
 *         * Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)
 *         {} matches a single character in the list {} (case sensitive)
 *     \{ matches the character { literally (case sensitive)
 *     Non-capturing group (?:[^}]*\}){8}
 *     {8} Quantifier — Matches exactly 8 times
 *     Match a single character not present in the list below [^}]*
 *     \} matches the character } literally (case sensitive)
 */

; This regex is if you will always have the same number of braces ("{" and "}").
; The key to understanding this is that "[^{}]" means "any character that is not { or }".
RegExMatch(Haystack, "`a)(^|\R)\K\s*""5656""\R\s+\{[^{}]*""prefab""[^{}]*\{(?:[^}]*\}){8}", UnquotedOutputVar)
MsgBox,, 1st Option, % UnquotedOutputVar
;-----------------------------------------------------------------------------------------------------------------------


; 2nd option------------------------------------------------------------------------------------------------------------
/*  from https://regex101.com/r/VHzUsz/2
 *     /
 *     (?:^|\R)\K\s*"5656"\R\s+(\{(?>[^{}]|(?1))*\})
 *     /
 *     ms
 *     Non-capturing group (?:^|\R)
 *         1st Alternative ^
 *             ^ asserts position at start of a line
 *         2nd Alternative \R
 *             \R matches any Unicode newline sequence; can be modified using verbs
 *     \K resets the starting point of the reported match. Any previously consumed characters are no longer included in the final match
 *     \s*
 *         matches any whitespace character (equal to [\r\n\t\f\v ])
 *         * Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)
 *     "5656" matches the characters "5656" literally (case sensitive)
 *     \R matches any Unicode newline sequence; can be modified using verbs
 *     \s+
 *         matches any whitespace character (equal to [\r\n\t\f\v ])
 *         + Quantifier — Matches between one and unlimited times, as many times as possible, giving back as needed (greedy)
 *     1st Capturing Group (\{(?>[^{}]|(?1))*\})
 *         \{ matches the character { literally (case sensitive)
 *         Atomic Group (?>[^{}]|(?1))*
 *             This group does not allow any backtracking to occur
 *             * Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)
 *             1st Alternative [^{}]
 *                 Match a single character not present in the list below [^{}]
 *                 {} matches a single character in the list {} (case sensitive)
 *             2nd Alternative (?1)
 *                 (?1) recurses the 1st subpattern
 *     \} matches the character } literally (case sensitive)
 *     Global pattern flags
 *     m modifier: multi line. Causes ^ and $ to match the begin/end of each line (not only begin/end of string)
 *     s modifier: single line. Dot matches newline characters 
 */

; This uses regex recusion (see: Matching Balanced Constructs https://www.regular-expressions.info/recurse.html)
; It will always match a balanced number of { and }, but it requires an extra step (the while loop) to check if the
; match contains "prefab".
StartingPosition := 1, Result := ""
while FoundPos := RegExMatch(Haystack, "`a)(?:^|\R)\K\s*""5656""\R\s+(\{(?>[^{}]|(?1))*\})", UnquotedOutputVar, StartingPosition)
{
    ; MsgBox % A_Index
    if InStr(UnquotedOutputVar, """prefab""")
    {
        Result := UnquotedOutputVar
        break
    }
    else
        StartingPosition := FoundPos + StrLen(UnquotedOutputVar)
}
MsgBox,, 2nd Option, % Result
;-----------------------------------------------------------------------------------------------------------------------


; 3rd option------------------------------------------------------------------------------------------------------------
/*  from https://autohotkey.com/boards/viewtopic.php?p=229951#p229951
 *     I think the RegExMatch should do is:
 *     1)search for this word "%A_Tab%%A_Tab%}`r`n%A_Tab%%A_Tab%"5656"`r`n%A_Tab%%A_Tab%{"
 *     2)consume anything after that word until encountering this word "`r`n%A_Tab%%A_Tab%}"
 *     3)if the matched case has a word "prefab" then stop searching and put to variable. else find another match
 *     
 *     see explanation at https://regex101.com/r/VHzUsz/3
 */
StartingPosition := 1, Result := ""
while FoundPos := RegExMatch(Haystack, "`ams)^`t`t""5656""\R`t`t\{.*?\R`t`t\}", UnquotedOutputVar, StartingPosition)
{   
    ; MsgBox % A_Index
    if InStr(UnquotedOutputVar, """prefab""")
    {
        Result := UnquotedOutputVar
        break
    }
    else
        StartingPosition := FoundPos + StrLen(UnquotedOutputVar)
}
MsgBox,, 3rd Option, % Result
;-----------------------------------------------------------------------------------------------------------------------

Thank you very much Datapoint for a very clear explanation, That was amazing. Those methods are overwhelming. But I am going to stick on 1st option you showed because loops makes slower results.

How about a case that:
1) "prefab" and "used_by_heroes" should exist inside the matched content using option 1
2) the contents can be randomized example. The code below are all valid, and each content of this 5656 sections will be detected by the regexmatch:

Code: Select all

		"5656"
		{
			"name"		"Brooch of the Gleaming Seal"
			"prefab"		"wearable"
			"creation_date"		"2013-11-06"
			"image_inventory"		"econ/items/phantom_assassin/lodas_pa_set__head/lodas_pa_set__head"
			"item_description"		"#DOTA_Item_Desc_Brooch_of_the_Gleaming_Seal"
			"item_name"		"#DOTA_Item_Brooch_of_the_Gleaming_Seal"
			"item_rarity"		"uncommon"
			"item_slot"		"head"
			"item_type_name"		"#DOTA_WearableType_Honored_Brooch"
			"model_player"		"models/items/phantom_assassin/lodas_pa_set__head/lodas_pa_set__head.vmdl"
			"portraits"
			{
				"icon"
				{
					"PortraitLightPosition"		"76.932938 -29.410818 221.487381"
					"PortraitLightAngles"		"38.671875 155.000610 0.000000"
					"PortraitLightFOV"		"34.000000"
					"PortraitLightDistance"		"130.000000"
					"PortraitLightColor"		"254 254 254"
					"PortraitShadowColor"		"97 97 97"
					"PortraitShadowScale"		"1.500000"
					"PortraitGroundShadowScale"		"1.500000"
					"PortraitAmbientColor"		"148 148 148"
					"PortraitAmbientScale"		"2.750000"
					"PortraitSpecularColor"		"251 74 84"
					"PortraitSpecularDirection"		"0.000000 0.000000 -1.000000"
					"PortraitSpecularPower"		"16.000000"
					"PortraitBackgroundColor1"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor2"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor3"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor4"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundTexture"		"materials/vgui/econ/item_icon_bg.vmat"
					"PortraitAnimationActivity"		"ACT_DOTA_CAPTURE"
					"PortraitAnimationCycle"		"0.000000"
					"PortraitAnimationRate"		"0.000000"
					"PortraitHideHero"		"0"
					"PortraitLightScale"		"1.750000"
					"PortraitAmbientDirection"		"197.904 4.526 -33.190"
					"cameras"
					{
						"default"
						{
							"PortraitPosition"		"187.467773 -76.296227 122.148560"
							"PortraitAngles"		"351.513062 155.308228 2.109375"
							"PortraitFOV"		"23.000000"
							"PortraitFar"		"1000.000000"
						}
					}
				}
			}
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"used_by_heroes"
			{
				"npc_dota_hero_phantom_assassin"		"1"
			}
			"branding"
			{
				"team_id"		"111474"
			}
		}
		"5656"
		{
			"portraits"
			{
				"icon"
				{
					"PortraitLightPosition"		"76.932938 -29.410818 221.487381"
					"PortraitLightAngles"		"38.671875 155.000610 0.000000"
					"PortraitLightFOV"		"34.000000"
					"PortraitLightDistance"		"130.000000"
					"PortraitLightColor"		"254 254 254"
					"PortraitShadowColor"		"97 97 97"
					"PortraitShadowScale"		"1.500000"
					"PortraitGroundShadowScale"		"1.500000"
					"PortraitAmbientColor"		"148 148 148"
					"PortraitAmbientScale"		"2.750000"
					"PortraitSpecularColor"		"251 74 84"
					"PortraitSpecularDirection"		"0.000000 0.000000 -1.000000"
					"PortraitSpecularPower"		"16.000000"
					"PortraitBackgroundColor1"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor2"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor3"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor4"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundTexture"		"materials/vgui/econ/item_icon_bg.vmat"
					"PortraitAnimationActivity"		"ACT_DOTA_CAPTURE"
					"PortraitAnimationCycle"		"0.000000"
					"PortraitAnimationRate"		"0.000000"
					"PortraitHideHero"		"0"
					"PortraitLightScale"		"1.750000"
					"PortraitAmbientDirection"		"197.904 4.526 -33.190"
					"cameras"
					{
						"default"
						{
							"PortraitPosition"		"187.467773 -76.296227 122.148560"
							"PortraitAngles"		"351.513062 155.308228 2.109375"
							"PortraitFOV"		"23.000000"
							"PortraitFar"		"1000.000000"
						}
					}
				}
			}
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"used_by_heroes"
			{
				"npc_dota_hero_phantom_assassin"		"1"
			}
			"branding"
			{
				"team_id"		"111474"
			}
			"name"		"Brooch of the Gleaming Seal"
			"prefab"		"wearable"
			"creation_date"		"2013-11-06"
			"image_inventory"		"econ/items/phantom_assassin/lodas_pa_set__head/lodas_pa_set__head"
			"item_description"		"#DOTA_Item_Desc_Brooch_of_the_Gleaming_Seal"
			"item_name"		"#DOTA_Item_Brooch_of_the_Gleaming_Seal"
			"item_rarity"		"uncommon"
			"item_slot"		"head"
			"item_type_name"		"#DOTA_WearableType_Honored_Brooch"
			"model_player"		"models/items/phantom_assassin/lodas_pa_set__head/lodas_pa_set__head.vmdl"
		}
		"5656"
		{
			"used_by_heroes"
			{
				"npc_dota_hero_phantom_assassin"		"1"
			}
			"portraits"
			{
			"prefab"		"wearable"
				"icon"
				{
					"PortraitLightPosition"		"76.932938 -29.410818 221.487381"
					"PortraitLightAngles"		"38.671875 155.000610 0.000000"
					"PortraitLightFOV"		"34.000000"
					"PortraitLightDistance"		"130.000000"
					"PortraitLightColor"		"254 254 254"
					"PortraitShadowColor"		"97 97 97"
					"PortraitShadowScale"		"1.500000"
					"PortraitGroundShadowScale"		"1.500000"
					"PortraitAmbientColor"		"148 148 148"
					"PortraitAmbientScale"		"2.750000"
					"PortraitSpecularColor"		"251 74 84"
					"PortraitSpecularDirection"		"0.000000 0.000000 -1.000000"
					"PortraitSpecularPower"		"16.000000"
					"PortraitBackgroundColor1"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor2"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor3"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor4"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundTexture"		"materials/vgui/econ/item_icon_bg.vmat"
					"PortraitAnimationActivity"		"ACT_DOTA_CAPTURE"
					"PortraitAnimationCycle"		"0.000000"
					"PortraitAnimationRate"		"0.000000"
					"PortraitHideHero"		"0"
					"PortraitLightScale"		"1.750000"
					"PortraitAmbientDirection"		"197.904 4.526 -33.190"
					"cameras"
					{
						"default"
						{
							"PortraitPosition"		"187.467773 -76.296227 122.148560"
							"PortraitAngles"		"351.513062 155.308228 2.109375"
							"PortraitFOV"		"23.000000"
							"PortraitFar"		"1000.000000"
						}
					}
				}
			}
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"branding"
			{
				"team_id"		"111474"
			}
			"name"		"Brooch of the Gleaming Seal"
			"creation_date"		"2013-11-06"
			"image_inventory"		"econ/items/phantom_assassin/lodas_pa_set__head/lodas_pa_set__head"
			"item_description"		"#DOTA_Item_Desc_Brooch_of_the_Gleaming_Seal"
			"item_name"		"#DOTA_Item_Brooch_of_the_Gleaming_Seal"
			"item_rarity"		"uncommon"
			"item_slot"		"head"
			"item_type_name"		"#DOTA_WearableType_Honored_Brooch"
			"model_player"		"models/items/phantom_assassin/lodas_pa_set__head/lodas_pa_set__head.vmdl"
		}

Use this haystack example for instance:

Code: Select all

Haystack2=
(
		"5654"
		{
			"name"		"Belt of the Gleaming Seal"
			"prefab"		"wearable"
			"creation_date"		"2013-11-06"
			"image_inventory"		"econ/items/phantom_assassin/lodas_pa_set__belt/lodas_pa_set__belt"
			"item_description"		"#DOTA_Item_Desc_Belt_of_the_Gleaming_Seal"
			"item_name"		"#DOTA_Item_Belt_of_the_Gleaming_Seal"
			"item_slot"		"belt"
			"item_type_name"		"#DOTA_WearableType_Honored_Belt"
			"model_player"		"models/items/phantom_assassin/lodas_pa_set__belt/lodas_pa_set__belt.vmdl"
			"portraits"
			{
				"icon"
				{
					"PortraitLightPosition"		"76.932938 -29.410818 221.487381"
					"PortraitLightAngles"		"57.661743 141.822510 0.000000"
					"PortraitLightFOV"		"46.000000"
					"PortraitLightDistance"		"242.000000"
					"PortraitLightColor"		"254 254 254"
					"PortraitShadowColor"		"97 97 97"
					"PortraitShadowScale"		"1.500000"
					"PortraitGroundShadowScale"		"1.500000"
					"PortraitAmbientColor"		"148 148 148"
					"PortraitAmbientScale"		"2.750000"
					"PortraitSpecularColor"		"251 74 84"
					"PortraitSpecularDirection"		"0.000000 0.000000 -1.000000"
					"PortraitSpecularPower"		"16.000000"
					"PortraitBackgroundColor1"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor2"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor3"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor4"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundTexture"		"materials/vgui/econ/item_icon_bg.vmat"
					"PortraitAnimationActivity"		"ACT_DOTA_CAPTURE"
					"PortraitAnimationCycle"		"0.000000"
					"PortraitAnimationRate"		"0.000000"
					"PortraitHideHero"		"0"
					"PortraitLightScale"		"1.750000"
					"PortraitAmbientDirection"		"197.904 4.526 -33.190"
					"cameras"
					{
						"default"
						{
							"PortraitPosition"		"182.981750 -85.518150 126.108841"
							"PortraitAngles"		"8.997803 154.621582 2.109375"
							"PortraitFOV"		"22.000000"
							"PortraitFar"		"1000.000000"
						}
					}
				}
			}
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"used_by_heroes"
			{
				"npc_dota_hero_phantom_assassin"		"1"
			}
			"branding"
			{
				"team_id"		"111474"
			}
		}
		"5656"
		{
			"used_by_heroes"
			{
				"npc_dota_hero_phantom_assassin"		"1"
			}
			"portraits"
			{
			"prefab"		"wearable"
				"icon"
				{
					"PortraitLightPosition"		"76.932938 -29.410818 221.487381"
					"PortraitLightAngles"		"38.671875 155.000610 0.000000"
					"PortraitLightFOV"		"34.000000"
					"PortraitLightDistance"		"130.000000"
					"PortraitLightColor"		"254 254 254"
					"PortraitShadowColor"		"97 97 97"
					"PortraitShadowScale"		"1.500000"
					"PortraitGroundShadowScale"		"1.500000"
					"PortraitAmbientColor"		"148 148 148"
					"PortraitAmbientScale"		"2.750000"
					"PortraitSpecularColor"		"251 74 84"
					"PortraitSpecularDirection"		"0.000000 0.000000 -1.000000"
					"PortraitSpecularPower"		"16.000000"
					"PortraitBackgroundColor1"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor2"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor3"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor4"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundTexture"		"materials/vgui/econ/item_icon_bg.vmat"
					"PortraitAnimationActivity"		"ACT_DOTA_CAPTURE"
					"PortraitAnimationCycle"		"0.000000"
					"PortraitAnimationRate"		"0.000000"
					"PortraitHideHero"		"0"
					"PortraitLightScale"		"1.750000"
					"PortraitAmbientDirection"		"197.904 4.526 -33.190"
					"cameras"
					{
						"default"
						{
							"PortraitPosition"		"187.467773 -76.296227 122.148560"
							"PortraitAngles"		"351.513062 155.308228 2.109375"
							"PortraitFOV"		"23.000000"
							"PortraitFar"		"1000.000000"
						}
					}
				}
			}
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"branding"
			{
				"team_id"		"111474"
			}
			"name"		"Brooch of the Gleaming Seal"
			"creation_date"		"2013-11-06"
			"image_inventory"		"econ/items/phantom_assassin/lodas_pa_set__head/lodas_pa_set__head"
			"item_description"		"#DOTA_Item_Desc_Brooch_of_the_Gleaming_Seal"
			"item_name"		"#DOTA_Item_Brooch_of_the_Gleaming_Seal"
			"item_rarity"		"uncommon"
			"item_slot"		"head"
			"item_type_name"		"#DOTA_WearableType_Honored_Brooch"
			"model_player"		"models/items/phantom_assassin/lodas_pa_set__head/lodas_pa_set__head.vmdl"
		}
		"5655"
		{
			"name"		"Cape of the Gleaming Seal"
			"prefab"		"wearable"
			"creation_date"		"2013-11-06"
			"image_inventory"		"econ/items/phantom_assassin/lodas_pa_set__cape/lodas_pa_set__cape"
			"item_description"		"#DOTA_Item_Desc_Cape_of_the_Gleaming_Seal"
			"item_name"		"#DOTA_Item_Cape_of_the_Gleaming_Seal"
			"item_slot"		"back"
			"item_type_name"		"#DOTA_WearableType_Honored_Cape"
			"model_player"		"models/items/phantom_assassin/lodas_pa_set__cape/lodas_pa_set__cape.vmdl"
			"portraits"
			{
				"icon"
				{
					"PortraitLightPosition"		"-104.916451 137.334091 203.602936"
					"PortraitLightAngles"		"43.143311 298.712769 0.000000"
					"PortraitLightFOV"		"46.000000"
					"PortraitLightDistance"		"242.000000"
					"PortraitLightColor"		"254 254 254"
					"PortraitShadowColor"		"97 97 97"
					"PortraitShadowScale"		"1.500000"
					"PortraitGroundShadowScale"		"1.500000"
					"PortraitAmbientColor"		"148 148 148"
					"PortraitAmbientScale"		"2.750000"
					"PortraitSpecularColor"		"251 74 84"
					"PortraitSpecularDirection"		"0.000000 0.000000 -1.000000"
					"PortraitSpecularPower"		"16.000000"
					"PortraitBackgroundColor1"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor2"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor3"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor4"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundTexture"		"materials/vgui/econ/item_icon_bg.vmat"
					"PortraitAnimationActivity"		"ACT_DOTA_CAPTURE"
					"PortraitAnimationCycle"		"0.272000"
					"PortraitAnimationRate"		"0.000000"
					"PortraitHideHero"		"0"
					"PortraitLightScale"		"1.750000"
					"PortraitAmbientDirection"		"197.904 4.526 -33.190"
					"cameras"
					{
						"default"
						{
							"PortraitPosition"		"-295.851105 165.136505 186.125473"
							"PortraitAngles"		"20.522461 331.534424 2.109375"
							"PortraitFOV"		"37.000000"
							"PortraitFar"		"1000.000000"
						}
					}
				}
			}
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"used_by_heroes"
			{
				"npc_dota_hero_phantom_assassin"		"1"
			}
			"branding"
			{
				"team_id"		"111474"
			}
		}
		"5656"
		{
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"used_by_heroes"
			{
				"npc_dota_hero_phantom_assassin"		"1"
			}
			"branding"
			{
				"team_id"		"111474"
			}
		}
		"5657"
		{
			"name"		"Ornaments of the Gleaming Seal"
			"prefab"		"wearable"
			"creation_date"		"2013-11-06"
			"image_inventory"		"econ/items/phantom_assassin/lodas_pa_set__shoulders/lodas_pa_set__shoulders"
			"item_description"		"#DOTA_Item_Desc_Ornaments_of_the_Gleaming_Seal"
			"item_name"		"#DOTA_Item_Ornaments_of_the_Gleaming_Seal"
			"item_rarity"		"rare"
			"item_slot"		"shoulder"
			"item_type_name"		"#DOTA_WearableType_Honored_Shoulders"
			"model_player"		"models/items/phantom_assassin/lodas_pa_set__shoulders/lodas_pa_set__shoulders.vmdl"
			"portraits"
			{
				"icon"
				{
					"PortraitLightPosition"		"76.932938 -29.410818 221.487381"
					"PortraitLightAngles"		"57.661743 141.822510 0.000000"
					"PortraitLightFOV"		"46.000000"
					"PortraitLightDistance"		"242.000000"
					"PortraitLightColor"		"254 254 254"
					"PortraitShadowColor"		"97 97 97"
					"PortraitShadowScale"		"1.500000"
					"PortraitGroundShadowScale"		"1.500000"
					"PortraitAmbientColor"		"148 148 148"
					"PortraitAmbientScale"		"2.750000"
					"PortraitSpecularColor"		"251 74 84"
					"PortraitSpecularDirection"		"0.000000 0.000000 -1.000000"
					"PortraitSpecularPower"		"16.000000"
					"PortraitBackgroundColor1"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor2"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor3"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor4"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundTexture"		"materials/vgui/econ/item_icon_bg.vmat"
					"PortraitAnimationActivity"		"ACT_DOTA_CAPTURE"
					"PortraitAnimationCycle"		"0.000000"
					"PortraitAnimationRate"		"0.000000"
					"PortraitHideHero"		"0"
					"PortraitLightScale"		"1.750000"
					"PortraitAmbientDirection"		"197.904 4.526 -33.190"
					"cameras"
					{
						"default"
						{
							"PortraitPosition"		"187.467773 -76.296227 122.148560"
							"PortraitAngles"		"357.363281 155.198364 2.109375"
							"PortraitFOV"		"24.000000"
							"PortraitFar"		"1000.000000"
						}
					}
				}
			}
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"used_by_heroes"
			{
				"npc_dota_hero_phantom_assassin"		"1"
			}
			"branding"
			{
				"team_id"		"111474"
			}
		}
		"5656"
		{
			"name"		"Brooch of the Gleaming Seal"
			"prefab"		"wearable"
			"creation_date"		"2013-11-06"
			"image_inventory"		"econ/items/phantom_assassin/lodas_pa_set__head/lodas_pa_set__head"
			"item_description"		"#DOTA_Item_Desc_Brooch_of_the_Gleaming_Seal"
			"item_name"		"#DOTA_Item_Brooch_of_the_Gleaming_Seal"
			"item_rarity"		"uncommon"
			"item_slot"		"head"
			"item_type_name"		"#DOTA_WearableType_Honored_Brooch"
			"model_player"		"models/items/phantom_assassin/lodas_pa_set__head/lodas_pa_set__head.vmdl"
			"portraits"
			{
				"icon"
				{
					"PortraitLightPosition"		"76.932938 -29.410818 221.487381"
					"PortraitLightAngles"		"38.671875 155.000610 0.000000"
					"PortraitLightFOV"		"34.000000"
					"PortraitLightDistance"		"130.000000"
					"PortraitLightColor"		"254 254 254"
					"PortraitShadowColor"		"97 97 97"
					"PortraitShadowScale"		"1.500000"
					"PortraitGroundShadowScale"		"1.500000"
					"PortraitAmbientColor"		"148 148 148"
					"PortraitAmbientScale"		"2.750000"
					"PortraitSpecularColor"		"251 74 84"
					"PortraitSpecularDirection"		"0.000000 0.000000 -1.000000"
					"PortraitSpecularPower"		"16.000000"
					"PortraitBackgroundColor1"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor2"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor3"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor4"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundTexture"		"materials/vgui/econ/item_icon_bg.vmat"
					"PortraitAnimationActivity"		"ACT_DOTA_CAPTURE"
					"PortraitAnimationCycle"		"0.000000"
					"PortraitAnimationRate"		"0.000000"
					"PortraitHideHero"		"0"
					"PortraitLightScale"		"1.750000"
					"PortraitAmbientDirection"		"197.904 4.526 -33.190"
					"cameras"
					{
						"default"
						{
							"PortraitPosition"		"187.467773 -76.296227 122.148560"
							"PortraitAngles"		"351.513062 155.308228 2.109375"
							"PortraitFOV"		"23.000000"
							"PortraitFar"		"1000.000000"
						}
					}
				}
			}
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"branding"
			{
				"team_id"		"111474"
			}
		}
		"5657"
		{
			"name"		"Ornaments of the Gleaming Seal"
			"prefab"		"wearable"
			"creation_date"		"2013-11-06"
			"image_inventory"		"econ/items/phantom_assassin/lodas_pa_set__shoulders/lodas_pa_set__shoulders"
			"item_description"		"#DOTA_Item_Desc_Ornaments_of_the_Gleaming_Seal"
			"item_name"		"#DOTA_Item_Ornaments_of_the_Gleaming_Seal"
			"item_rarity"		"rare"
			"item_slot"		"shoulder"
			"item_type_name"		"#DOTA_WearableType_Honored_Shoulders"
			"model_player"		"models/items/phantom_assassin/lodas_pa_set__shoulders/lodas_pa_set__shoulders.vmdl"
			"portraits"
			{
				"icon"
				{
					"PortraitLightPosition"		"76.932938 -29.410818 221.487381"
					"PortraitLightAngles"		"57.661743 141.822510 0.000000"
					"PortraitLightFOV"		"46.000000"
					"PortraitLightDistance"		"242.000000"
					"PortraitLightColor"		"254 254 254"
					"PortraitShadowColor"		"97 97 97"
					"PortraitShadowScale"		"1.500000"
					"PortraitGroundShadowScale"		"1.500000"
					"PortraitAmbientColor"		"148 148 148"
					"PortraitAmbientScale"		"2.750000"
					"PortraitSpecularColor"		"251 74 84"
					"PortraitSpecularDirection"		"0.000000 0.000000 -1.000000"
					"PortraitSpecularPower"		"16.000000"
					"PortraitBackgroundColor1"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor2"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor3"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor4"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundTexture"		"materials/vgui/econ/item_icon_bg.vmat"
					"PortraitAnimationActivity"		"ACT_DOTA_CAPTURE"
					"PortraitAnimationCycle"		"0.000000"
					"PortraitAnimationRate"		"0.000000"
					"PortraitHideHero"		"0"
					"PortraitLightScale"		"1.750000"
					"PortraitAmbientDirection"		"197.904 4.526 -33.190"
					"cameras"
					{
						"default"
						{
							"PortraitPosition"		"187.467773 -76.296227 122.148560"
							"PortraitAngles"		"357.363281 155.198364 2.109375"
							"PortraitFOV"		"24.000000"
							"PortraitFar"		"1000.000000"
						}
					}
				}
			}
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"used_by_heroes"
			{
				"npc_dota_hero_phantom_assassin"		"1"
			}
			"branding"
			{
				"team_id"		"111474"
			}
		}
		"5656"
		{
			"name"		"Brooch of the Gleaming Seal"
			"prefab"		"wearable"
			"creation_date"		"2013-11-06"
			"image_inventory"		"econ/items/phantom_assassin/lodas_pa_set__head/lodas_pa_set__head"
			"item_description"		"#DOTA_Item_Desc_Brooch_of_the_Gleaming_Seal"
			"item_name"		"#DOTA_Item_Brooch_of_the_Gleaming_Seal"
			"item_rarity"		"uncommon"
			"item_slot"		"head"
			"item_type_name"		"#DOTA_WearableType_Honored_Brooch"
			"model_player"		"models/items/phantom_assassin/lodas_pa_set__head/lodas_pa_set__head.vmdl"
			"portraits"
			{
				"icon"
				{
					"PortraitLightPosition"		"76.932938 -29.410818 221.487381"
					"PortraitLightAngles"		"38.671875 155.000610 0.000000"
					"PortraitLightFOV"		"34.000000"
					"PortraitLightDistance"		"130.000000"
					"PortraitLightColor"		"254 254 254"
					"PortraitShadowColor"		"97 97 97"
					"PortraitShadowScale"		"1.500000"
					"PortraitGroundShadowScale"		"1.500000"
					"PortraitAmbientColor"		"148 148 148"
					"PortraitAmbientScale"		"2.750000"
					"PortraitSpecularColor"		"251 74 84"
					"PortraitSpecularDirection"		"0.000000 0.000000 -1.000000"
					"PortraitSpecularPower"		"16.000000"
					"PortraitBackgroundColor1"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor2"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor3"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor4"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundTexture"		"materials/vgui/econ/item_icon_bg.vmat"
					"PortraitAnimationActivity"		"ACT_DOTA_CAPTURE"
					"PortraitAnimationCycle"		"0.000000"
					"PortraitAnimationRate"		"0.000000"
					"PortraitHideHero"		"0"
					"PortraitLightScale"		"1.750000"
					"PortraitAmbientDirection"		"197.904 4.526 -33.190"
					"cameras"
					{
						"default"
						{
							"PortraitPosition"		"187.467773 -76.296227 122.148560"
							"PortraitAngles"		"351.513062 155.308228 2.109375"
							"PortraitFOV"		"23.000000"
							"PortraitFar"		"1000.000000"
						}
					}
				}
			}
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"used_by_heroes"
			{
				"npc_dota_hero_phantom_assassin"		"1"
			}
			"branding"
			{
				"team_id"		"111474"
			}
		}
		"5656"
		{
			"portraits"
			{
				"icon"
				{
					"PortraitLightPosition"		"76.932938 -29.410818 221.487381"
					"PortraitLightAngles"		"38.671875 155.000610 0.000000"
					"PortraitLightFOV"		"34.000000"
					"PortraitLightDistance"		"130.000000"
					"PortraitLightColor"		"254 254 254"
					"PortraitShadowColor"		"97 97 97"
					"PortraitShadowScale"		"1.500000"
					"PortraitGroundShadowScale"		"1.500000"
					"PortraitAmbientColor"		"148 148 148"
					"PortraitAmbientScale"		"2.750000"
					"PortraitSpecularColor"		"251 74 84"
					"PortraitSpecularDirection"		"0.000000 0.000000 -1.000000"
					"PortraitSpecularPower"		"16.000000"
					"PortraitBackgroundColor1"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor2"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor3"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundColor4"		"1.000000 1.000000 1.000000"
					"PortraitBackgroundTexture"		"materials/vgui/econ/item_icon_bg.vmat"
					"PortraitAnimationActivity"		"ACT_DOTA_CAPTURE"
					"PortraitAnimationCycle"		"0.000000"
					"PortraitAnimationRate"		"0.000000"
					"PortraitHideHero"		"0"
					"PortraitLightScale"		"1.750000"
					"PortraitAmbientDirection"		"197.904 4.526 -33.190"
					"cameras"
					{
						"default"
						{
							"PortraitPosition"		"187.467773 -76.296227 122.148560"
							"PortraitAngles"		"351.513062 155.308228 2.109375"
							"PortraitFOV"		"23.000000"
							"PortraitFar"		"1000.000000"
						}
					}
				}
			}
			"price_info"
			{
				"bucket"		"Normal"
				"class"		"NoPrice"
				"category_tags"		"Equipment"
				"date"		"1/13/2014"
				"price"		"0"
			}
			"used_by_heroes"
			{
				"npc_dota_hero_phantom_assassin"		"1"
			}
			"branding"
			{
				"team_id"		"111474"
			}
			"name"		"Brooch of the Gleaming Seal"
			"prefab"		"wearable"
			"creation_date"		"2013-11-06"
			"image_inventory"		"econ/items/phantom_assassin/lodas_pa_set__head/lodas_pa_set__head"
			"item_description"		"#DOTA_Item_Desc_Brooch_of_the_Gleaming_Seal"
			"item_name"		"#DOTA_Item_Brooch_of_the_Gleaming_Seal"
			"item_rarity"		"uncommon"
			"item_slot"		"head"
			"item_type_name"		"#DOTA_WearableType_Honored_Brooch"
			"model_player"		"models/items/phantom_assassin/lodas_pa_set__head/lodas_pa_set__head.vmdl"
		}

)

;;; RegEx to scan 5656 with "prefab" and "used_by_heroes" that might be randomized on the section's contents?
[/color]
Developer of AJOM's DOTA2 MOD Master, Easiest way to MOD your DOTA2 without the use of internet :lol: . I created this program using Autohotkey thats why I love Autohotkey and the community!

GitHub:
https://github.com/Aldrin-John-Olaer-Manalansan
User avatar
Datapoint
Posts: 294
Joined: 18 Mar 2018, 17:06

Re: Condition that a "WORD" is inside a Matched "algorithm" on RegExMatch Operation

24 Jul 2018, 00:16

aldrinjohnom wrote:Thank you very much Datapoint for a very clear explanation, That was amazing. Those methods are overwhelming. But I am going to stick on 1st option you showed because loops makes slower results
If it only loops 1 or 2 times it might not be so bad.

Right now I am going to suggest option#3 with if InStr(UnquotedOutputVar, """prefab""") && InStr(UnquotedOutputVar, """"used_by_heroes"""". There might be a way to do it with a single Regex, but I can't think of one right now. I will think some more, but option #3 is going to be a lot easier to code and maintain.
aldrinjohnom wrote:How about a case that:
1) "prefab" and "used_by_heroes" should exist inside the matched content using option 1
2) the contents can be randomized example. The code below are all valid, and each content of this 5656 sections will be detected by the regexmatch:
If you know that they will always be in a specific order, then 1 regex is easier. But if you don't know if "prefab" comes before or after "used_by_heroes" it is more difficult.
aldrinjohnom
Posts: 77
Joined: 18 Apr 2018, 08:49

Re: Condition that a "WORD" is inside a Matched "algorithm" on RegExMatch Operation

24 Jul 2018, 02:11

Datapoint wrote:
aldrinjohnom wrote:Thank you very much Datapoint for a very clear explanation, That was amazing. Those methods are overwhelming. But I am going to stick on 1st option you showed because loops makes slower results
If it only loops 1 or 2 times it might not be so bad.
I currently plan this regex to be inside a parsing loop:

Code: Select all

param=5656,3523,12,3153,6345,1235,6234,12312,...,...,..,...
loop,parse,param
{
	regex
}

so adding a while loop on each of regex creates a nested loop, which when looping almost 100 parameters, it is almost 5x slower. Also the database that I currently use is almost 100000 lines, Looping around will result a slower effect when there are almost "5" matches each loop regex :cry:

Datapoint wrote: Right now I am going to suggest option#3 with if InStr(UnquotedOutputVar, """prefab""") && InStr(UnquotedOutputVar, """"used_by_heroes"""". There might be a way to do it with a single Regex, but I can't think of one right now. I will think some more, but option #3 is going to be a lot easier to code and maintain.
Please Please! Im looking forward to :shifty:

Datapoint wrote:
aldrinjohnom wrote:How about a case that:
1) "prefab" and "used_by_heroes" should exist inside the matched content using option 1
2) the contents can be randomized example. The code below are all valid, and each content of this 5656 sections will be detected by the regexmatch:
If you know that they will always be in a specific order, then 1 regex is easier. But if you don't know if "prefab" comes before or after "used_by_heroes" it is more difficult.
That explains everything. So does that mean that it is not possible to do 1 regex? :cry:
Developer of AJOM's DOTA2 MOD Master, Easiest way to MOD your DOTA2 without the use of internet :lol: . I created this program using Autohotkey thats why I love Autohotkey and the community!

GitHub:
https://github.com/Aldrin-John-Olaer-Manalansan
aldrinjohnom
Posts: 77
Joined: 18 Apr 2018, 08:49

Re: Condition that a "WORD" is inside a Matched "algorithm" on RegExMatch Operation

24 Jul 2018, 11:06

Bring Up My Post
Developer of AJOM's DOTA2 MOD Master, Easiest way to MOD your DOTA2 without the use of internet :lol: . I created this program using Autohotkey thats why I love Autohotkey and the community!

GitHub:
https://github.com/Aldrin-John-Olaer-Manalansan
awel20
Posts: 211
Joined: 19 Mar 2018, 14:09

Re: Condition that a "WORD" is inside a Matched "algorithm" on RegExMatch Operation  Topic is solved

24 Jul 2018, 17:01

Code: Select all

Haystack := Clipboard  ; use clipboard data for testing

RegExMatch(Haystack, "`am)^\t{2}""5656""\R\t{2}\{\R"
	. "(?(DEFINE)(?'lines'\t{3}.*$\R))"
	. "((?P>lines)*"
	. "(\t{3}""used_by_heroes"".*$\R)"
	. "(?P>lines)*"
	. "(\t{3}""prefab"".*$\R)"
	. "(?P>lines)*|"
	. "(?P>lines)*"
	. "(\t{3}""prefab"".*$\R)"
	. "(?P>lines)*"
	. "(\t{3}""used_by_heroes"".*$\R)"
	. "(?P>lines)*)"
	. "^\t{2}\}"
	, UnquotedOutputVar)
	
MsgBox % UnquotedOutputVar
ExitApp
https://regex101.com/r/MhjiXO/1/
https://regex101.com/r/MhjiXO/2/
aldrinjohnom
Posts: 77
Joined: 18 Apr 2018, 08:49

Re: Condition that a "WORD" is inside a Matched "algorithm" on RegExMatch Operation

24 Jul 2018, 21:13

awel20 wrote:

Code: Select all

Haystack := Clipboard  ; use clipboard data for testing

RegExMatch(Haystack, "`am)^\t{2}""5656""\R\t{2}\{\R"
	. "(?(DEFINE)(?'lines'\t{3}.*$\R))"
	. "((?P>lines)*"
	. "(\t{3}""used_by_heroes"".*$\R)"
	. "(?P>lines)*"
	. "(\t{3}""prefab"".*$\R)"
	. "(?P>lines)*|"
	. "(?P>lines)*"
	. "(\t{3}""prefab"".*$\R)"
	. "(?P>lines)*"
	. "(\t{3}""used_by_heroes"".*$\R)"
	. "(?P>lines)*)"
	. "^\t{2}\}"
	, UnquotedOutputVar)
	
MsgBox % UnquotedOutputVar
ExitApp
https://regex101.com/r/MhjiXO/1/
https://regex101.com/r/MhjiXO/2/

Holy! That was exactly what I was looking for, That fixes the problem!

Can you explain how this regex works in step by step? It seems that this regex contains extraterrestrial expressions on it :wtf: . Anyway, Topic Solved!
Developer of AJOM's DOTA2 MOD Master, Easiest way to MOD your DOTA2 without the use of internet :lol: . I created this program using Autohotkey thats why I love Autohotkey and the community!

GitHub:
https://github.com/Aldrin-John-Olaer-Manalansan
awel20
Posts: 211
Joined: 19 Mar 2018, 14:09

Re: Condition that a "WORD" is inside a Matched "algorithm" on RegExMatch Operation

25 Jul 2018, 10:27

https://regex101.com/r/MhjiXO/2/ wrote:

Code: Select all

^\t{2}"5656"\R\t{2}\{\R
(?(DEFINE)(?'line'\t{3}.*\R)
(?'hero'\t{3}"used_by_heroes".*\R)
(?'pre'\t{3}"prefab".*\R))
((?P>line)*(?P>hero)(?P>line)*(?P>pre)(?P>line)*|
(?P>line)*(?P>pre)(?P>line)*(?P>hero)(?P>line)*)
^\t{2}\}
Generally, the idea is this: the first two lines and the last line all start with exactly two tabs. All the other lines start with at least three tabs.
There are three types of lines that start with three tabs: 1) A line that contains "used_by_heroes". 2) A line that contains "prefab". 3) All other lines.
It will match either: 3 1 3 2 3 or 3 2 3 1 3
(?(DEFINE)...) stores a pattern so that it can be used later. (?(DEFINE)(?'line'\t{3}.*\R)) means that any times you see (?P>line) it is the same as (\t{3}.*\R). Just like if you had copy-and-pasted it at that spot.
I suggest looking at the links I gave for a more detailed explanation of every symbol.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Jaroz, ntepa and 126 guests