it's me again. I asked a question similar to this some time ago, but this question is a bit more complicated. I planned to use RegexKitLite to do what I needed, but I believe that this can be done without it. I have an NSString in which there are a few words with spaces / spaces, and I want to get the last space in the line that is to the left of the last word. Example Line below:
NSString *string = @"Here is an example string HELLO ";
As you can see in the line above, there is a space / space at the very end of the line. I want to get a space / space to the left of HELLO and replace it with my own text / line. I am working on using NSString NSBackwardsSearch, but it does not work.
NSString *spaceReplacement = @"text that i want"; NSString *replaced = [snipet [string rangeOfString:substring options:NSBackwardsSearch].location:@" " withString:spaceReplacement]; NSLog(@"%@", replaced);
Any help would help, I'm just tired of trying to fix it, it made me intimidated. I thought I could do it with RegexKitLite, but the learning curve for this is too steep for me, given my time frame with which I work. I am glad that Jacob R. suggested that I use the NSString methods :-)
source share