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)
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!!!