Searching for certain string

Hey all. I have no idea how to do this, but basically what I’m trying to do is detect a certain string in a sentence without knowing that string. What I’m trying to do is allow a user to enter in their favorite something so that the system can read it and store it. For example, I want the user to be able to type something like, “My favorite color is blue,” and have the system store that information in a string list, let’s say a list of the user’s favorite things. That way when the user asks the system what the user’s favorite color is, it will respond with the information the user entered in.
Is there any way you can detect the string that follows the word “favorite” so that the system knows what favorite item it is?

What you’re asking is not related to Unity, or at least Unity has nothing that would help you achieve that. What you want to do is pretty hard, you have to parse a text and understand it’s meaning so you can save it, and parse another text and understand it’s meaning to search the correct answer. What you asked at the end is a lot more simple, you can use string.IndexOf to find the index of “favorite” in a string, then string.Substring to get whatever is writen after “favorite”.

But what you asked and what you want or really far in complexity. You probably shouldn’t just find the word favorite and then get what’s next. In your example “favorite” is followed by “color is blue”, so you must understand that it’s talking about a “color”, and that it’s “blue”, and ignore the “is”. But you’ll have to validate that there’s an “is” there, or maybe not, it depends of how real the input should be. Also, if the user types “my favorite rpg game is fallout” you now have to understand that “rpg game” is something, so you have cases with one or more words for the thing. Maybe you want to understand things like “my favorite engines are unity and unreal”, so now you have a complex favorite, and the connector is “are” instead of “is”. This all depends on how much freedom you want to give the user.

Also, “my favorite color is blue” should obviously be a valid input, but what about “my asdasdasd favorite color is blue”? Or “favorite color blue”? Or “Your favorite color is qwe blue and dog”?

What I’m trying to say is that what you’re trying to do sounds really complex, unless you do something a lot more structured, like showing a already writen sentence and allowing only certain input on key positions.