Remove prefix from NSString
14,790
NSString *prefixToRemove = @"test";
NSString *newString = [originalString copy];
if ([originalString hasPrefix:prefixToRemove])
newString = [originalString substringFromIndex:[prefixToRemove length]];
Author by
atomikpanda
Updated on June 27, 2022Comments
-
atomikpanda almost 2 years
How can I delete the prefix "test" from a NSString? I've tried
stringByReplacingOccurrencesOfString:
but it's not what I want because it's the prefix that I want to remove not from the other occurrences of the string.