Remove Characters and Everything After from String

后端 未结 2 1049
梦如初夏
梦如初夏 2020-12-31 17:09

I am aware of replacing Strings of a String, but that only works if I know exactly what I want to remove.

If I have a String like the following:

\"hi-there-t

2条回答
  •  情歌与酒
    2020-12-31 17:57

    It can be done without REGEX like this:

    NSString *string = @"hi-there-this-is-a-test&feature=hi-there";
        NSRange range = [string rangeOfString:@"&feature"];
        NSString *shortString = [string substringToIndex:range.location];
    

提交回复
热议问题