I am trying to make a simple markup language, and I need my Cocoa app to be able to read it. I would prefer to have that code written in Objective-c, but I am happy to use any other language.
Here is my current problem. I am using this code:
for (int character = 1; character < ([script length] - 1); character ++) {
NSLog(@"%@", [[script substringToIndex:character] substringFromIndex:([[script substringToIndex:character] length] - 2)]);
Unfortunately, if I pass the string [button] through it, it shows this in the debug console:
[
[b
[bu
[but
[butt
[__NSCFConstantString substringWithRange:]: Range or index out of bounds
I can sort out the error message, but I need to know how to read the script and recognize certain tags like [button]. Can anybody give me a link to something useful on this subject?
Just to give you examples:
Output:
And a more interesting case:
Which produces: