So, before I describe my problem you need some context: I have some custom file that describe some objects by text. One of the lines of this file looks like this:
...
~
InWalls:
[0](Name = "Wall", Pos = 1|2, Rot = 7)
~
...
my program reads this file like so
join all lines in file
delete all spaces
split line by "~"
for(each line)
4.1 split by ":"
4.2 swith on first (in this case it's "InWalls")
4.3 find in second "(", ")" and substring between (we get "Name = "Wall", Pos = 1|2, Rot = 7")
4.4 split by ","
4.5 each split by "="
4... do staff and so on..
Really simple concept, isn't? Basically, as you understand, I use String.Split()
and String.SubString()
a lot, and everything working.. BUT!! What if my string looks like this..
...
~
InWalls:
[0](Name = "Wall (1)", Pos = 1|2, Rot = 7)
~
...
here on step 4.3 I will get not "Name = "Wall (1)", Pos = 1|2, Rot = 7", BUT "Name = "Wall (1", and I don't know how to fix this.. I need property "Name", and I can't just cut off this part... Does some has any thoughts on that?