开发者

How to get a string after another string in ObjectiveC?

开发者 https://www.devze.com 2023-04-07 10:54 出处:网络
For example, the text is: my na开发者_StackOverflow中文版me is angie merkel and Im stupid! I\'d like to get the angie merkel from the string.

For example, the text is:

my na开发者_StackOverflow中文版me is angie merkel and Im stupid!

I'd like to get the angie merkel from the string.

How can i do this? My head is going to explode... i can't trim this string because it's a variable

(text from the user for a ChatBot)


If the string always has the format `my name is and Im stupid!', you can do the following:

NSString *name = [[startingString stringByReplacingOccurrencesOfString:@"my name is " 
                                                            withString:@""]
                  stringByReplacingOccurrencesOfString:@" and Im stupid!" 
                                            withString:@""];
0

精彩评论

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