J
J
justslipknot2020-06-11 16:55:48
Algorithms
justslipknot, 2020-06-11 16:55:48

How to extract text inside brackets?

There is a structure like this:

"item"
{
"inner-item-1" "value"
"inner-item-2"  "value"
"inner-item-3" "value"
    {
        "subitem-1"
    }
    {
        "subitem-2"
    }
}


How to get all the content inside the curly braces of the "item" element, given that there are many such elements in the file?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
2
2CHEVSKII, 2020-06-11
@justslipknot

SteamDB has a lib for parsing vdf -> https://github.com/SteamDatabase/ValveKeyValue
But I didn't find the docks, either blind or they don't exist. Well, look at the decompiler, what's there like.

S
Stalker_RED, 2020-06-11
@Stalker_RED

find the starting "item" and the parenthesis behind it, remember the position.
declare a variable "counter of brackets" with value = 1
then iterate character by character, counting the number of open brackets, add +1 for each open bracket, subtract for each closed bracket.
when the counter reaches zero - remember the position of the last parenthesis.
take everything between the first and last.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question