[C#] [Q] Yes another parsing thing, I know
-
Trying to parse this kind of file (but I don't think you can use regex):
Version 165 31 { Locked False Skinned False BoneCount 0 Mask 255 Bounds { Aabb { Min -22.43750000 -22.71933000 -16.95572000 Max 26.19019000 21.00463000 22.58556000 } } Geometries { Geometry { ShaderIndex 0 Flags - VertexDeclaration N51263BB5 Indices 20352 { 3345 0 1202 1202 1851 3345 1852 3474 836 836 3471 1852 1853 3477 0 0 3345 1853 3525 1200 3480 3480 1854 3525 1855 3485 2823 2823 3483 1855 } Vertices 3650 { 0.96892170 20.41658000 1.23570400 / -0.23576470 0.97100060 0.03965970 / 255 255 255 255 / 0.16036900 -0.32604200 / -0.79340060 -0.16875510 -0.58483950 1.00000000 } } } }
I'd like to be able to grab the
Indices
andVertices
parts in-between the curly's. Anyone know how I can do this, or even what language this is in?If it helps it's an openFormat's file for a
.ydr
. (.mesh
file).
-
This will work for my purposes I guess lol
public static string[] ReadBracedLines(string[] lines, string parameterName) { List<string> linesList = lines.ToList(); int indexStart = linesList.FindIndex(x => x.Contains(parameterName)); int indexEnd = linesList.FindIndex(indexStart, i => i.Contains("}")); int nextBraceIndex = linesList.FindIndex(indexStart, i => i.Contains("{")) + 1; string[] indicies = linesList.GetRange(nextBraceIndex, indexEnd - nextBraceIndex).ToArray(); return indicies.ToArray(); } // E.g. string[] indexLines = ReadBracedLines(lines.ToArray(), "Indices"); // return value: 3345 0 1202 1202 1851 3345 1852 3474 836 836 3471 1852 1853 3477 0 0 3345 1853 3525 1200 3480 3480 1854 3525 1855 3485 2823 2823 3483 1855
Trust me the function name is the best I could come up with. I was originally going with
ReadBetweenTheLines
.
-
OH F**K IT WORKED!
(it's an asteroid
)