开发者

Remove the first 4 letters from string

Hi I am having a string as G531开发者_StackOverflow Other Dough Products.

Here I want only Other Dough Products, reply me with code.

I tried with substring but that is not working.

Thanks in advance .


You don't actually say what you tried but substringFromIndex:

NSString *str = @"G531 Other Dough Products";
str = [str substringFromIndex:5];

should do the trick.

You'll probably find that you want to use 5 unless you want the leading space in your new string.


NSString* s = [@"G531 Other Dough Products" substringFromIndex:5];


Try using "substringFromIndex" (see documentation)


He He, you can also do this as below,

NSString * newString = [NSString stringWithCString:(const char*)&"G531 Other Dough Products"[5] encoding:NSUTF8StringEncoding];
NSLog(@"%@", newString); 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜