0

For example, the text is:

my name 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)

1 Answer 1

1

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:@""];
Sign up to request clarification or add additional context in comments.

4 Comments

Can you describe what you're trying to do a little more carefully? It's not clear.
I read a ".qa"-file. One line of this file is: my name is <name>;[Ah your name is <name> very interesting!] so i check if the user says "my name is" and i'd like to find out, what the user says after "my name is" and then i save this to a NSMutableDictionary
So you want everything after "my name is " up until the semicolon?
yes but not until the semicolon, coz i have the variable "question" which is already until the semicolon. In the user sentence after "my name is"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.