I have a JSON object as a string in a textarea, and I want to figure out which lines certain values are on. I would like to do this so that a line numbers thing that scrolls with the textarea made of an ordered list of values formatted the same would have the singular number have a different style when a selected actual JSON value is used (1, 5, -11). I have figured that I can just find the string index of the first occurrence of the value, then count the number of "\n" until it reaches it, and then cut all of the parts before and including the part just cut out, and try again.
But my problem is that whenever I want to search for, say, 1, it returns to me every number containing 1, some of which are: "11" (it would do this one twice, which is the issue), "-1" (it would find the "1" in "-1"), "-11" (both of the previous issues combined), "41" and "15" (it finds the 1 in there as well).
A list of it would typically look like this:
{
"points":[
[-1,-1,-1],
[1,-1,-1],
[-1,1,-1],
[-1,-1,1],
[1,1,-1],
[1,-1,1],
[-1,1,1],
[1,1,1]
],
"faces":[
[0,1,4,2],
[0,1,5,3],
[0,2,6,3],
[3,5,7,6],
[2,4,7,6],
[1,4,7,5]
],
"colors":[
"red",
"green",
"blue",
"yellow",
"black",
"white"
],
"borders":[
"black",
"black",
"black",
"black",
"black",
"black"
]
}
where I single out the faces area, as that is the part I want to use, and only that part, and find the specific values of it. They made go into the double digits, which is where the problem would start occurring.
I have thought of a solution being to look and make sure there is at least a "[", a ",", or a " " on the immediate left side of the value, and at least a "]", a ",", or a " " on the right side of the value. But I can't figure out an easily expandable solution.
How could I manage that, hopefully without having 9 separate if statements to check for each sequence, and finding which is the closest?