我有一个字符串对象,其中包含许多颜色代码,例如ci=0,0,0
和ci=0,25,225
我想在两个颜色代码之间取一个子字符串,并更改该范围内的颜色。有没有人有一个简单的方法来完成这项任务?
例如:
ci=0,0,0You are at a walkway.
ci=0,0,0You are facing west. You see the ci=0,32,225creature controller roomci=0,0,0 to the ci=0,32,225northci=0,0,0
每个ci=0,0,0
都是不同颜色的标签,应该为紧随其后的字符串显示。
我想删除ci颜色代码,只显示文字,但颜色正确。
答案 0 :(得分:0)
使用此:
NSString *testString= @"0,0,0You are at a walkway";
NSArray *array = [testString componentsSeparatedByString:@","];
你会得到:
array[0] = "0"
array[1] = "0"
array[2] = "0You are at a walkway"
如果您还在“... 0You ...”中添加逗号“0”和“您”之间的逗号,则会更容易,因为您将拥有:
array[0] = "0"
array[1] = "0"
array[2] = "0"
array[3] = "You are at a walkway"